polyglot-python
Write Python in your own language, deterministically.
polyglot-python is a keyword transpiler for Python. You keep Python's grammar and write programs with localized keywords; polyglot-python maps those keywords to the real Python keywords and hands the result to CPython. No AI, no network, no randomness: the same source, locale and version always produce byte-identical Python.
It is not a prose-to-code translator and it does not guess intent. It is Python syntax with your words.
Install
pip install polyglot-python
pip install -e . # from source
Requires Python 3.12+. Python 3.10/3.11 are not supported because their tokenizer splits Indic combining marks, so several Hindi keywords would not translate. No runtime dependencies.
Node.js users can install the thin npm wrapper. It forwards every command to the Python CLI, so the Python package must be installed as well.
npm install -g polyglot-python
Quick start
examples/classify.tr:
fonksiyon classify(n):
eğer n % 15 == 0:
döndür "FizzBuzz"
değilse_eğer n % 3 == 0:
döndür "Fizz"
değilse_eğer n % 5 == 0:
döndür "Buzz"
değilse:
döndür str(n)
için n içinde range(1, 16):
print(classify(n))
polyglot-python run examples/classify.tr
polyglot-python check examples/classify.tr
polyglot-python translate examples/classify.tr
polyglot-python translate examples/classify.tr -o classify.py
The same FizzBuzz program is included for every locale under examples/.
Locales
| Code | Language | if |
def |
return |
|---|---|---|---|---|
| tr | Türkçe | eğer |
fonksiyon |
döndür |
| es | Español | si |
función |
devolver |
| pt | Português | se |
função |
retornar |
| de | Deutsch | wenn |
funktion |
zurückgeben |
| fr | Français | si |
fonction |
retourner |
| zh | 中文 | 如果 |
函数 |
返回 |
| hi | हिन्दी | अगर |
फलन |
लौटाओ |
| ar | العربية | إذا |
دالة |
إرجاع |
| ru | Русский | если |
определить |
вернуть |
polyglot-python locales prints the full list. Every locale defines exactly the 35
Python hard keywords (keyword.kwlist); soft keywords such as match, case
and type stay English.
Locale selection order:
--lang CODE- first line directive:
# polyglot-python: tr - file suffix:
.tr,.es,.pt,.de,.fr,.zh,.hi,.ar,.ru
CLI
polyglot-python run FILE [--lang CODE] [args...]
polyglot-python check FILE [--lang CODE]
polyglot-python translate FILE [--lang CODE] [-o OUT]
polyglot-python locales
polyglot-python --version
For run, place options before FILE; everything after FILE is passed to the
program as sys.argv[1:].
Guarantees
- Only exact
NAMEtokens that match a locale keyword are rewritten. Strings, comments, f-strings, numbers, identifiers and attribute names are untouched. - Line numbers are preserved one-to-one; a per-line column map translates reported error positions back to the localized source.
translate -oand stdout output are UTF-8 with LF line endings on every platform, so exports are byte-identical and re-verifiable.checktranslates and compiles without executing the program, so localized sources can be validated safely.- A localized keyword after a dot is treated as an attribute name and never rewritten.
- Localized keywords are reserved words in their locale.
- Missing files, invalid UTF-8, unknown locales and untokenizable input fail with a clear message; nothing is guessed or silently skipped.
- Error headers are localized; CPython's detail text (for example
ZeroDivisionError) remains English for now. - Exit codes from the executed program are propagated.
Limits
- Phase 1 localizes keywords only: no localization of builtins (
print,range, ...), the standard library, or English exception text. - This is not a natural-language compiler. It does not understand Spanish or Turkish prose; it understands Python syntax written with localized keywords.
- The local prototype ships 9 locales. Other languages can be added by editing
src/polyglot_python/locales.json; malformed tables are rejected at load time. - Tested on CPython 3.12 on Windows; CI covers 3.12-3.14 on Linux and 3.12 on Windows and macOS. The code targets 3.12+.
Development
python -m venv .venv
.venv/Scripts/pip install -e ".[dev]"
.venv/Scripts/python -m pytest -q --cov=polyglot_python --cov-fail-under=100
The suite contains 120 tests with 100% statement coverage, including every keyword in both directions for all 9 locales, end-to-end CLI runs of every example, version consistency with the changelog and the npm wrapper, and byte-level determinism checks. CI runs Ubuntu 3.12-3.14 plus Windows and macOS at 3.12, enforces the 100% coverage gate on Linux 3.12, translates every example twice on all three operating systems to compare bytes and line counts, builds the wheel, installs it into a clean environment, and smoke-tests it, and runs the npm wrapper against the installed Python package. Dependabot keeps GitHub Actions and development dependencies current. Separate release workflows publish tagged GitHub Releases to PyPI and npm through Trusted Publishing.
Releasing
Publishing uses Trusted Publishing for both registries and stores no API token.
- Configure the trusted publishers once:
- PyPI: publisher for project
polyglot-python: ownerFurox-Art, repositorypolyglot-python, workflowrelease.yml, environmentpypi. - npm: trusted publisher for package
polyglot-python: ownerFurox-Art, repositorypolyglot-python, workflowrelease-npm.yml, environmentnpm.
- PyPI: publisher for project
- Change
versioninpyproject.toml,src/polyglot_python/__init__.pyandnpm/package.jsontogether; the test suite rejects drift. - Publish a GitHub Release with tag
v<version>.release.ymlverifies the tag, builds the sdist and wheel, and uploads them to PyPI;release-npm.ymlverifies the same version and publishesnpm/to npm with provenance.
License
MIT
Metadata
Release files for polyglot-python 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| polyglot_python-0.2.1.tar.gz | 21.0 kB | With provenance | Details for polyglot_python-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polyglot_python-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for polyglot_python-0.2.1-py3-none-any.whl |
Total release size: 35.7 kB
Release files / polyglot_python-0.2.1.tar.gz
| Download URL | polyglot_python-0.2.1.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bbebb599488b0b6f7a2daf0bbe00a50ab95257094a14998a6ef5ca8e2a23df21
|
|
BLAKE2b-256 checksum How to use checksums |
ebdc3d54bf8bef79e87524aaa5c4cd38a539aa53865b667f74ca5f639866fd8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logRelease files / polyglot_python-0.2.1-py3-none-any.whl
| Download URL | polyglot_python-0.2.1-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46608bcdc3dd8d7cff40707e8b01934782c4079ee93cd88864a633979946e3ce
|
|
BLAKE2b-256 checksum How to use checksums |
b76d95001b31f83f6817d603d609ea6e501e4a661fa6bb6cde0a7eb5280267f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logSecurity for polyglot-python 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for polyglot_python-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.