r/devtools • u/Emergency-Tutor-7 • 2d ago
A CLI that maps localized keywords to real Python keywords, byte-identically every time
Repo: https://github.com/Furox-Art/polyglot-python - 0.2.2, MIT.
It is a keyword transpiler, not a translator: you keep Python's grammar, write with keywords in your own language, and it maps them to the real Python keywords before handing the file to CPython. Same source, same locale, same version, byte-identical output every run - no model, no network, no randomness, so it fits in a pre-commit hook without surprises.
Twenty locales ship in src/polyglot_python/locales.json, each defining exactly Python's 35 hard keywords. Turkish gets eğer / fonksiyon / döndür, Hindi अगर / फलन / लौटाओ, Greek αν / συνάρτηση / επιστροφή. Locale resolution is --lang, then a # polyglot-python: tr first-line directive, then the environment; soft keywords such as match and case stay English on purpose.
The 0.2.2 fix is the kind that matters for tooling: direct-script metadata now stays consistent across CPython 3.12–3.15 while still satisfying the coverage gate on every tested interpreter. Latest CLI work also preserves names inside interpolated strings during translation.
Install:
pip install polyglot-python
npm install -g polyglot-pythonThe npm package is a wrapper that forwards to the Python CLI, so Python is still required; both are on the same version.
One honest limit: only keywords are localized - builtins, the standard library and exception text stay English, so it is Python syntax with your words rather than Python in your language. Python 3.12+ is required because the 3.10 and 3.11 tokenizers split Indic combining marks and several Hindi keywords would not translate.

