Skip to content

Instantly share code, notes, and snippets.

@sertraline
Created November 19, 2021 07:24
Show Gist options
  • Save sertraline/76cb5e6d8ca4f32982b5bcc7493a8e52 to your computer and use it in GitHub Desktop.
Save sertraline/76cb5e6d8ca4f32982b5bcc7493a8e52 to your computer and use it in GitHub Desktop.
Translate latin into cyrillic
const mapCyrillic = {
KeyQ: 'й',
KeyW: 'ц',
KeyE: 'у',
KeyR: 'к',
KeyT: 'е',
KeyY: 'н',
KeyU: 'г',
KeyI: 'ш',
KeyO: 'щ',
KeyP: 'з',
BracketLeft: 'х',
BracketRight: 'ъ',
KeyA: 'ф',
KeyS: 'ы',
KeyD: 'в',
KeyF: 'а',
KeyG: 'п',
KeyH: 'р',
KeyJ: 'о',
KeyK: 'л',
KeyL: 'д',
Semicolon: 'ж',
Quote: 'э',
KeyZ: 'я',
KeyX: 'ч',
KeyC: 'с',
KeyV: 'м',
KeyB: 'и',
KeyN: 'т',
KeyM: 'ь',
Comma: 'б',
Period: 'ю'
};
const mapLatin = {
KeyQ: 'q',
KeyW: 'w',
KeyE: 'e',
KeyR: 'r',
KeyT: 't',
KeyY: 'y',
KeyU: 'u',
KeyI: 'i',
KeyO: 'o',
KeyP: 'p',
BracketLeft: '[',
BracketRight: ']',
KeyA: 'a',
KeyS: 's',
KeyD: 'd',
KeyF: 'f',
KeyG: 'g',
KeyH: 'h',
KeyJ: 'j',
KeyK: 'k',
KeyL: 'l',
Semicolon: ';',
Quote: '\'',
KeyZ: 'z',
KeyX: 'x',
KeyC: 'c',
KeyV: 'v',
KeyB: 'b',
KeyN: 'n',
KeyM: 'm',
Comma: ',',
Period: '.'
};
let query = 'dfk.nf';
query = query.split('');
query.forEach((char, idx) => {
Object.keys(mapLatin).forEach((key) => {
if (char === mapLatin[key]) {
query[idx] = mapCyrillic[key];
}
});
});
query = query.join('');
console.log(query);
// валюта
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment