CyrTranslit
Bi-directional Cyrillic transliterator for Python. Transliterate Cyrillic text to Latin and vice versa.
By default, transliterates for the Serbian language but a language flag can be set in order to transliterate Macedonian and Montenegrin.
What is transliteration?
Transliteration is the conversion of a text from one script to another. For instance, a Latin transliteration of the Serbian phrase "Република Косово", usually translated as "Republika Kosovo", is "Republika Kosovo".
Usage
Installation
CyrTransit is hosted in the Python Package Index (PyPi) so it can be installed using pip:
python -m pip install cyrtranslit # latest version
python -m pip install cyrtranslit==0.3 # specific version
python -m pip install cyrtranslit>=0.3 # minimum version
List supported languages
>>> import cyrtranslit
>>> cyrtranslit.supported()
>>> ['me', 'sr', 'mk', 'ru']
From Cyrillic to Latin
Serbian
>>> import cyrtranslit
>>> cyrtranslit.to_latin("Република Косово")
>>> "Republika Kosovo"
Macedonian
>>> import cyrtranslit
>>> cyrtranslit.to_latin("Република Косово", "mk")
>>> "Republika Kosovo"
Montenegrin
>>> import cyrtranslit
>>> cyrtranslit.to_latin("Република Косово", "me")
>>> "Republika Kosovo"
Russian
>>> import cyrtranslit
>>> cyrtranslit.to_latin("Республика Косово", "ru")
>>> "Recpublika Kosovo"
From Latin to Cyrillic
Serbian
>>> import cyrtranslit
>>> cyrtranslit.to_cyrillic("Republika Kosovo")
>>> "Република Косово"
Macedonian
>>> import cyrtranslit
>>> cyrtranslit.to_cyrillic("Republika Kosovo", "mk")
>>> "Република Косово"
Montenegrin
>>> import cyrtranslit
>>> cyrtranslit.to_cyrillic("Republika Kosovo", "me")
>>> "Република Косово"
Russian
>>> import cyrtranslit
>>> cyrtranslit.to_cyrillic("Respublika Kosovo", "ru")
>>> "Республика Косово"
Contribute a new Cyrillic alphabet
Simply create a new transliteration dictionary in the mapper.py file and reference to it in the TRANSLIT_DICT dictionary.
Consider contributing support for the following Cyrillic alphabets:
- Bulgarian
- Ukranian