Ana Mari Noel
Ana Mari Noel

Reputation: 21

JavaScript built in charset library

How to convert text from Latin to Cyrillic.

Is there is any javascript built-in lib with chars array to avoid creating the custom array with wanted characters?

Upvotes: 1

Views: 72

Answers (1)

Ana Mari Noel
Ana Mari Noel

Reputation: 21

I was unable to find a built-in JavaScript library.

The solution to this issue I found in this way.

/**
 * Cyrillic letters opposite from latin one.
 *
 * @type {JSON}
 */
const latinToCyrillicCharsets = {
    'a': 'а',
    'b': 'б',
    'v': 'в',
    'g': 'г',
    'd': 'д',
    'dj': 'ђ',
    'e': 'е',
    // 'ž': 'ж',
    'z': 'з',
    'i': 'и',
    'j': 'j',
    'k': 'к',
    'l': 'л',
    'lj': 'љ',
    'm': 'м',
    'n': 'н',
    'nj': 'њ',
    'o': 'о',
    'p': 'п',
    'r': 'р',
    's': 'с',
    't': 'т',
    // 'ć': 'ћ',
    'u': 'у',
    'f': 'ф',
    'h': 'х',
    'c': 'ц',
    // 'č': 'ч',
    // 'dž': 'џ',
    // 'š': 'ш',
};

Upvotes: 1

Related Questions