Ukrainian transliteration by official rules
Project description
transliteration-ua
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
-
List available
makecommands:make help
-
Check code style with:
make lint -
Run tests using:
make test
-
Manage dependencies via Poetry:
make poetry args="<poetry-args>"
- For example:
make poetry args="add picodi"
- For example:
-
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
Credits
This project was generated with
yakimka/cookiecutter-pyproject.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6920b3410b608b550efbcb2577379577b8ba0deace6b247354016ab1f8c3a431
|
|
| MD5 |
0358f04e32ead2ba393febbc0e5d0c2b
|
|
| BLAKE2b-256 |
397b136a93d118f05df4fbab6b8a877d7da298f8df9aa4aea19f0866e0731db4
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8459f1a051743af520fe3e4eb2cf917242147d9ff923141967f5955277d05b63
|
|
| MD5 |
cb6e36b491dbf5bd86244302155e3130
|
|
| BLAKE2b-256 |
e1e88e838d85dad1bd8f17d17d67c9d95a7c5d91e083991efe6e60da4fdd265f
|