cyrillic-to-translit-js-sosa
v3.2.2
Published
Simple javascript function for converting Cyrillic symbols to Translit
Downloads
1
Maintainers
Readme
cyrillic-to-translit-js
Ultra-lightweight JavaScript library for converting Cyrillic symbols to Translit and vice versa
Install
npm install --save cyrillic-to-translit-js
Simple to use
import CyrillicToTranslit from 'cyrillic-to-translit-js';
const cyrillicToTranslit = new CyrillicToTranslit();
cyrillicToTranslit.transform('Какая-то строка', '_').toLowerCase();
Constructor
{ preset: 'ru' }
or empty - transliteration preset for Russian language.{ preset: 'uk' }
- transliteration preset for Ukranian language (see PR #27).{ preset: 'mn' }
- transliteration preset for Mongolian language (see PR #142).
transform()
Convert Cyrillic symbols to Translit
cyrillicToTranslit().transform(input, spaceReplacement);
input
- string which should be transformedspaceReplacement
- symbol for space replacement
reverse()
Convert Translit symbols to Cyrillic
cyrillicToTranslit().reverse(input, spaceReplacement);
input
- string which should be transformedspaceReplacement
- symbol for space replacement
Examples
- transform()
cyrillicToTranslit().transform('Привет Мир!');
>Privet Mir!
cyrillicToTranslit().transform('привет мир!', "_")
>privet_mir!
cyrillicToTranslit({ preset: "uk" }).transform('привіт світе!', "_")
>pryvit_svite!
- reverse()
cyrillicToTranslit().reverse("ulitsa Soyuza Pechatnikov")
>улица Союза Печатников
cyrillicToTranslit({ preset: "uk" }).reverse("Rozghon Uliana i Harashchenko Khrystyna")
>Розгон Уляна і Гаращенко Христина
Typescript
Typescript supports starting form v2.0.0. See definitions here
Credits
- kunashir
- Vasyl Gendzeliuk
- Nikita Svesnikov
- Igor Deryabin
- makepost
- Aleksey Kislov
- Igor Kamyshev
- Sasha Kirillov
- Booglejr
- Пүрэвжаргал
Why I've done this plugin?
https://alfilatov.com/posts/cyrillic-to-translit-js-library-for-converting-cyrillic-symbols-to-translit-and-vice-versa/
License
MIT © Aleksandr Filatov alfilatov.com