CyrTranslit

raw JSON →
1.2.0 verified Mon Apr 27 auth: no python

Bi-directional Cyrillic transliteration library supporting Belarusian, Bulgarian, Greek, Montenegrin, Macedonian, Mongolian, Russian, Serbian, Tajik, and Ukrainian. Current version 1.2.0, maintained on GitHub.

pip install cyrtranslit
error KeyError: 'xx'
cause Using an unsupported or misspelled language code.
fix
Check supported codes: 'be', 'bg', 'el', 'mk', 'mn', 'ru', 'sr', 'tg', 'uk'. Use lowercase.
error IndexError: string index out of range
cause This error occurred in older versions (<1.1.1) with Bulgarian words ending in 'sh'.
fix
Upgrade to cyrtranslit >=1.1.1.
error ModuleNotFoundError: No module named 'cyrillic_transliteration'
cause Trying to import with the incorrect package name (the GitHub repo name).
fix
Use 'import cyrtranslit' (the PyPI package name).
breaking Version 1.2.0 changes default to not preserve accented vowels (Ѐ/ѐ, Ѝ/ѝ). To preserve accents, use preserve_accents=True parameter.
fix Use cyrtranslit.to_latin(text, 'bg', preserve_accents=True) or cyrtranslit.to_latin(text, 'mk', preserve_accents=True) to keep grave accents.
gotcha Language codes are case-sensitive and must be two-letter lowercase (e.g., 'ru', 'sr', 'uk').
fix Always use lowercase language codes. Valid codes: 'be', 'bg', 'el', 'mk', 'mn', 'ru', 'sr', 'tg', 'uk'. 'mg' for Montenegrin is also supported.
deprecated Python 2 support has been dropped since version 0.4. The library no longer works with Python 2.
fix Use Python 3.6 or newer.

Basic usage demonstrating to_latin and to_cyrillic with language codes.

import cyrtranslit

# Transliterate Russian from Cyrillic to Latin
cyrillic_text = "Привет мир"
latin_text = cyrtranslit.to_latin(cyrillic_text, "ru")
print(latin_text)  # Output: Privet mir

# Transliterate Serbian from Latin to Cyrillic
latin_text = "Zdravo svete"
cyrillic_text = cyrtranslit.to_cyrillic(latin_text, "sr")
print(cyrillic_text)  # Output: Здраво свете