alifbo for Python
Python port of alifbo: Uzbek transliteration between Cyrillic, the previous Latin alphabet, and the Latin alphabet approved by Uzbekistan's Senate on 10 September 2026. The amending law still awaits the president's signature and is not yet in force.
The port has zero runtime dependencies, supports Python 3.9+, ships type hints (py.typed), and is tested against a fixture of more than 13,000 cases generated from the TypeScript build to produce identical output.
Install
pip install alifbo
Usage
from alifbo import fold_search_key, from_cyrillic, to_cyrillic, to_new_latin, to_old_latin
to_new_latin("O'zbekiston shaharlari")
# ConversionResult(text='Özbekiston şaharlari', warnings=())
to_old_latin("Özbekiston şaharlari").text
# 'Oʻzbekiston shaharlari'
result = from_cyrillic("Елена")
result.text
# 'Yelena'
result.warnings[0]
# Warning(index=0, length=1, rule='cyrillic.e.positional',
# message='Cyrillic е can represent e or ye; a positional rule was applied.',
# alternatives=('e', 'ye'))
to_cyrillic("Şavkat").text
# 'Шавкат'
fold_search_key("Шавкат") == fold_search_key("Shavkat")
# True
to_new_latin("MyShop shahar", protected_terms=["MyShop"]).text
# 'MyShop şahar'
API
Conversion functions return a frozen ConversionResult(text, warnings), where warnings is a tuple of frozen Warning(index, length, rule, message, alternatives) objects:
to_new_latin(text, **options): previous Latin to new Latin.to_old_latin(text, **options): new Latin to previous Latin.from_cyrillic(text, **options): Cyrillic to new Latin, with ambiguity warnings.to_cyrillic(text, **options): new Latin to Cyrillic, with ambiguity warnings.
Their keyword-only options mirror the TypeScript ConversionOptions:
| Python | TypeScript | Default |
|---|---|---|
protect_spans |
protectSpans |
True |
protected_terms |
protectedTerms |
None |
exceptions |
exceptions |
None |
ng_as_digraph |
ngAsDigraph |
True |
The other functions take only text:
fold_search_key(text): canonical new-Latin, NFC, locale-independent lowercase key.fold_search_key_loose(text): also strips diacritics. It can merge distinct words, so never use it as a unique key.normalize_apostrophes(text): folds apostrophe-like characters to U+02BB aftero/gand to U+02BC elsewhere.normalize_confusables(text): NFC-normalizes text and folds known confusables such as U+0219 to U+015F.detect_alphabet(text): returnsAlphabetDetection(alphabet, confidence).alphabetis one of'cyrillic','old-latin','new-latin','mixed', or'unknown'.
Differences from the TypeScript package
- Warning offsets are Python string indexes (code points). The TypeScript package reports UTF-16 code-unit offsets. The two are equal unless the text contains characters outside the Basic Multilingual Plane, such as emoji. For example,
from_cyrillic("😀 Елена")reports warnings at indexes[2, 4]in Python and[3, 5]in JavaScript. Offsets point into the text you passed in, before NFC normalization, exceptions, or (forto_cyrillic) the old-to-new Latin pre-pass, just as they do in TypeScript. - Names are snake_case, options are keyword arguments, and results are immutable dataclasses with tuples instead of arrays.
- An empty string used as an
exceptionskey is ignored. The TypeScript package can loop forever on one. - Unicode character properties come from the running Python's
unicodedatamodule. Characters added in newer Unicode versions may be classified differently than they are by your JavaScript engine.
Casing never uses Python's built-in string case methods. It uses the same explicit Latin and Cyrillic tables as the TypeScript package, so the Turkish İ/ı problem cannot occur.
Rules
The conversion pipeline, apostrophe handling, the sʼh boundary, Cyrillic ambiguity rules, and the open ng question are documented in the main README.
Development
From the repository root:
npm ci && npm run build && node scripts/gen-python-parity.mjs
cd python
uv run --with pytest pytest
uv run --with ruff ruff check . && uv run --with ruff ruff format --check .
Released under the MIT License.
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 alifbo-0.3.0.tar.gz.
File metadata
- Download URL: alifbo-0.3.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ba8911706bedde8b1178860c7d47ce2f84385de0c41877973cc5f72a52d603b
|
|
| MD5 |
28f70286405cb65810f9d008dac7700f
|
|
| BLAKE2b-256 |
fc2a5873ad6eb79e2c667fdb0ec470d8cd831093c7ee9bd7fea890b1da35f95e
|
Provenance
The following attestation bundles were made for alifbo-0.3.0.tar.gz:
Publisher:
publish.yml on azakapro/alifbo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alifbo-0.3.0.tar.gz -
Subject digest:
5ba8911706bedde8b1178860c7d47ce2f84385de0c41877973cc5f72a52d603b - Sigstore transparency entry: 2831356727
- Sigstore integration time:
-
Permalink:
azakapro/alifbo@da48b3071c038e8142744886ec726157bde034d8 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/azakapro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@da48b3071c038e8142744886ec726157bde034d8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file alifbo-0.3.0-py3-none-any.whl.
File metadata
- Download URL: alifbo-0.3.0-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cc4ddf4199be9e564e224eb3f3f668f386d1a0ea8c5af0ee919182c4cc2ac7a
|
|
| MD5 |
1f776e33dea6735ec20556f40c81d6ac
|
|
| BLAKE2b-256 |
3e96a7c4b34334acb3f5e81e5bb02f1ccafe1c8b26358d959cd5d0a9560fdefb
|
Provenance
The following attestation bundles were made for alifbo-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on azakapro/alifbo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alifbo-0.3.0-py3-none-any.whl -
Subject digest:
2cc4ddf4199be9e564e224eb3f3f668f386d1a0ea8c5af0ee919182c4cc2ac7a - Sigstore transparency entry: 2831356758
- Sigstore integration time:
-
Permalink:
azakapro/alifbo@da48b3071c038e8142744886ec726157bde034d8 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/azakapro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@da48b3071c038e8142744886ec726157bde034d8 -
Trigger Event:
push
-
Statement type: