Skip to main content

Ukrainian transliteration by official rules

Project description

transliteration-ua

Build Status Codecov PyPI - Version PyPI - Python Version PyPI - Downloads

Ukrainian transliteration by official rules

https://zakon.rada.gov.ua/laws/show/55-2010-п

Installation

pip install transliteration-ua

Example

To use transliteration-ua, import the transliterate_ua function and pass a Ukrainian string to it:

from transliteration_ua import transliterate_ua

# Basic usage
print(transliterate_ua("Привіт, Світ!"))
# Pryvit, Svit!

# Names are transliterated correctly
print(transliterate_ua("Андрій"))
# Andrii

# Words with an apostrophe are also handled
print(transliterate_ua("Короп'є"))
# Koropie

Custom transliteration function

If you need to create your own transliteration function with custom rules, you can use the make_transliterate_func factory. It accepts two mapping arguments: replacements for general character mappings and first_char_replacements for special mappings that apply only to the first letter of a word.

Here's how you can create a simplified transliterator:

from transliteration_ua import make_transliterate_func

# Define custom replacement rules
simple_replacements = {
    "а": "a",
    "б": "b",
    "в": "v",
    # ...
    # all the Ukrainian alphabet need to be defined here
}
# No special first character rules for this example
first_char_replacements = {}

# Create the custom function
simple_transliterate = make_transliterate_func(
    simple_replacements,
    first_char_replacements,
)

# Use it
print(simple_transliterate("баба"))
# baba

Development

Making Changes

  1. List available make commands:

    make help
    
  2. Check code style with:

    make lint
    
  3. Run tests using:

    make test
    
  4. Manage dependencies via Poetry:

    make poetry args="<poetry-args>"
    
    • For example: make poetry args="add picodi"
  5. For local CI debugging:

    make run-ci
    

Pre-commit Hooks

We use pre-commit for linting and formatting:

  • It runs inside a Docker container by default.
  • Optionally, set up hooks locally:
    pre-commit install
    

Mypy

We use mypy for static type checking.

It is configured for strictly typed code, so you may need to add type hints to your code. But don't be very strict, sometimes it's better to use Any type.

License

MIT

Credits

This project was generated with yakimka/cookiecutter-pyproject.

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

transliteration_ua-0.2.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

transliteration_ua-0.2.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file transliteration_ua-0.2.0.tar.gz.

File metadata

  • Download URL: transliteration_ua-0.2.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.12.10 Linux/6.11.0-1018-azure

File hashes

Hashes for transliteration_ua-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3afc81910b6b466ff5b8b3e10d97c77bc641e59bf696a7eb21933b6fb639a779
MD5 5772f57de10e652e7f06d91448044770
BLAKE2b-256 8d3e1e3c93a7b072c2a610313c00ed0c04b5d6fcd5a489b6845ed39592e9f86c

See more details on using hashes here.

File details

Details for the file transliteration_ua-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: transliteration_ua-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.12.10 Linux/6.11.0-1018-azure

File hashes

Hashes for transliteration_ua-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5d2edcf69396149541249b7505a90866d8ad51aba0c6a7cd2e8ef17da51c5dc
MD5 e758547ce5f780274c052c1e019c9fca
BLAKE2b-256 5dedaac57dc7bb8000c80a01e6d913d29668a1810eda0092d84b2e3362362f92

See more details on using hashes here.

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