Skip to main content

Mongolian Latin-Cyrillic transliteration library following MNS 5217:2012 standard

Project description

mn-translit

Mongolian Latin-Cyrillic transliteration following MNS 5217:2012 standard with proper Mongolian number grammar.

Python Version Support

  • Python 3.8+

Installation

pip install mn-translit

Or install from source:

git clone https://github.com/btseee/mn-translit.git
cd mn-translit
pip install -e .

Usage

Text Transliteration

from mn_translit import latin_to_cyrillic, cyrillic_to_latin

# Latin to Cyrillic
print(latin_to_cyrillic("Sain baina uu?"))
# Output: Сайн байна уу?

# With automatic number conversion (digits → words)
print(latin_to_cyrillic("Bi 21 nom baina", trans_num=True))
# Output: Би хорин нэг ном байна

# Cyrillic to Latin
print(cyrillic_to_latin("Монгол"))
# Output: Mongol

Command-line

Install and use the CLI directly:

echo "Sain baina uu?" | mn-translit --direction cyrillic
# → Сайн байна уу?

echo "Монгол" | mn-translit --direction latin
# → Mongol

echo "Bi 2024 ond" | mn-translit --direction cyrillic --trans-num
# → Би хоёр мянга хорин дөрвөн онд

Number Conversion

from mn_translit import number_to_words, words_to_number

# Number to words (proper Mongolian grammar)
print(number_to_words(21))
# Output: хорин нэг

print(number_to_words(111))
# Output: зуун арав нэг

print(number_to_words(230))
# Output: хоёр зуун гучин

print(number_to_words(2024))
# Output: хоёр мянга хорин дөрөв

# Words to number
print(words_to_number("мянга"))
# Output: 1000

print(words_to_number("хорин нэг"))
# Output: 21

print(words_to_number("хоёр зуун гучин"))
# Output: 230

Character Mapping

Basic Mapping

Latin Cyrillic Latin Cyrillic
a а n н
e э o о
i и u у
ö ө ü ү

Digraphs

Latin Cyrillic Latin Cyrillic
kh х ts ц
ch ч sh ш
zh ж ya я
ye е yo ё
yu ю

Diphthongs

Latin Cyrillic Example
ai ай sainai → сайнай
ei эй erdei → эрдэй
ii ий kharii → харий
oi ой oilgokh → ойлгох

Number System

Major Scales

  • 100 → зуун
  • 1,000 → мянга
  • 10,000 → түм
  • 100,000 → бум
  • 1,000,000 → сая
  • 1,000,000,000 → тэрбум
  • 1,000,000,000,000 → их наяд

Examples

  • 21 → хорин нэг
  • 31 → гучин нэг
  • 41 → дөчин нэг
  • 51 → тавин нэг
  • 61 → жаран нэг
  • 71 → далан нэг
  • 81 → наян нэг
  • 91 → ерэн нэг
  • 111 → зуун арав нэг
  • 230 → хоёр зуун гучин

Testing

Run the test suite to verify all functionality:

python tests/test_translit.py

Development

Setting up for development

git clone https://github.com/btseee/mn-translit.git
cd mn-translit
pip install -e .

Running tests

python tests/test_translit.py

Publishing to PyPI

This package uses GitHub Actions for automated publishing. To publish a new version:

  1. Update version in mn_translit/__init__.py
  2. Create a new release on GitHub
  3. The GitHub Action will automatically run tests and publish to PyPI

Note: You need to set up PYPI_API_TOKEN secret in your GitHub repository settings.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mn_translit-1.0.3.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mn_translit-1.0.3-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file mn_translit-1.0.3.tar.gz.

File metadata

  • Download URL: mn_translit-1.0.3.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mn_translit-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d0702bf912db3822548ab7b4bb0923bcf23921cc5df037e2c81a0f63a9f33b7d
MD5 c1ddac4e45f4430c030a4eaaf2d10882
BLAKE2b-256 ad23c1eece4cda3e3b5ebf000b2595a17922064627a8966cf680e0f79d761763

See more details on using hashes here.

Provenance

The following attestation bundles were made for mn_translit-1.0.3.tar.gz:

Publisher: python-package.yml on btseee/mn-translit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mn_translit-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: mn_translit-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mn_translit-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ce4a19b6d5cbfbdfffb00ed1856fdccf2d798cc2f8adbb71ef3dbed140706675
MD5 bfddc94564f41827afb0921d3c386292
BLAKE2b-256 a1a219962dbf68e2728905545bcfc0e25aca48464eae0bbc36912c6fb041c9be

See more details on using hashes here.

Provenance

The following attestation bundles were made for mn_translit-1.0.3-py3-none-any.whl:

Publisher: python-package.yml on btseee/mn-translit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page