Why Migrate to translit?¶
translit consolidates 8+ legacy Python Unicode text-processing libraries into a single, fast, MIT-licensed package.
The problem¶
A typical Django or Flask project that handles international text might depend on several of these packages:
| Package | Weekly downloads | License | Purpose |
|---|---|---|---|
| Unidecode | ~8M | GPL-2.0 | Unicode → ASCII |
| text-unidecode | ~6M | Artistic-1.0 | Unicode → ASCII |
| python-slugify | ~7M | MIT | Slug generation |
| awesome-slugify | ~50K | GPL-3.0 | Slug generation |
| anyascii | ~1M | ISC | Unicode → ASCII |
| confusable_homoglyphs | ~200K | MIT | Homoglyph detection |
| pathvalidate | ~2M | MIT | Filename sanitization |
| unicodedata2 | ~500K | PSF | Updated Unicode data |
That's 8 transitive dependencies, 4 different licenses (including GPL), and 8 different APIs to learn.
The solution¶
translit replaces all of them with one import:
# Before: 8 imports
from unidecode import unidecode
from slugify import slugify
from confusable_homoglyphs import confusables
import pathvalidate
# After: 1 import
import translit
Comparison¶
| Feature | Legacy | translit |
|---|---|---|
| Performance | Pure Python | Rust via PyO3 (benchmarks) |
| License | Mixed GPL/Artistic/MIT | MIT |
| API | 8 different APIs | One coherent API |
| Language profiles | 0–5 languages | 64 built-in |
| Type safety | Partial | Full py.typed + stubs |
| Confusable detection | Separate package | Built in |
| Filename sanitization | Separate package | Built in |
| Unicode version | Varies (often outdated) | Current |
Migration guides¶
Step-by-step migration from each legacy library:
- From Unidecode / text-unidecode — drop-in
unidecode()alias - From python-slugify / awesome-slugify — parameter-compatible
slugify() - From confusable_homoglyphs
- From pathvalidate
- From anyascii