L
L
Laziness of the Romanovs2019-05-31 20:21:10
JavaScript
Laziness of the Romanovs, 2019-05-31 20:21:10

Translate special characters in JavaScript?

The country uses a double alphabet (Cyrillic and English letters).
Both have special characters. I tried to make it easier for myself to enter / translate these characters.
I decided to use objects for this. A key-value is good as long as one character "spits out" a single character in response.
For example , How can I make sure that when I type "G," (the letter G followed by a comma ), it is treated as one "ғ" (this specific language letter) and returns the value for the same "ғ" from the object?

It's also not clear

как взамен двух букв вернуть одну (или обратное) - Ввел "YA", а получаешь "Я", а не в "ЙА" как сейчас реализовано.

You can try the JS code in the github
Webmord here

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Immortal_pony, 2019-05-31
@Immortal_pony

What is the question?
Everything has long been implemented without you. For example: https://www.npmjs.com/package/urlify

R
Robur, 2019-05-31
@Robur

store in the key not one letter but two.

const mySuperTranslateMap = {
 'Г,': 'ғ'
}

and in the text check two letters too.
how to broadcast if you have both "G" and "G" - a separate question, you can think of different things. From a primitive check from a longer length to a shorter one, to some tricky automata that will simply run through the line and give you the right one.

M
Maxim Timofeev, 2017-06-21
@NeveR3d

Doesn't work how? Mistakes?
and your submission should only go through if
your form A doesn't show that something like that would be sent, so most likely you get a funny word 'fasle' in response to your ajax, I think you wanted to write 'false'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question