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.1.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.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: transliteration_ua-0.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 6920b3410b608b550efbcb2577379577b8ba0deace6b247354016ab1f8c3a431
MD5 0358f04e32ead2ba393febbc0e5d0c2b
BLAKE2b-256 397b136a93d118f05df4fbab6b8a877d7da298f8df9aa4aea19f0866e0731db4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: transliteration_ua-0.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8459f1a051743af520fe3e4eb2cf917242147d9ff923141967f5955277d05b63
MD5 cb6e36b491dbf5bd86244302155e3130
BLAKE2b-256 e1e88e838d85dad1bd8f17d17d67c9d95a7c5d91e083991efe6e60da4fdd265f

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