Skip to content

Ultra-lightweight JavaScript library for converting Cyrillic symbols to Translit and vice versa

License

Notifications You must be signed in to change notification settings

TsPuujee/cyrillic-to-translit-js

 
 

Repository files navigation

cyrillic-to-translit-js

Codeship Status for greybax/cyrillic-to-translit-js

NPM version NPM Downloads/month Build Status Coveralls Status

Ultra-lightweight JavaScript library for converting Cyrillic symbols to Translit and vice versa

Demo page

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).

transform()

Convert Cyrillic symbols to Translit

cyrillicToTranslit().transform(input, spaceReplacement);

  • input - string which should be transformed
  • spaceReplacement - symbol for space replacement

reverse()

Convert Translit symbols to Cyrillic

cyrillicToTranslit().reverse(input, spaceReplacement);

  • input - string which should be transformed
  • spaceReplacement - 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

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

About

Ultra-lightweight JavaScript library for converting Cyrillic symbols to Translit and vice versa

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 79.0%
  • HTML 19.7%
  • TypeScript 1.3%