Legesher
OfficialThis MCP server translates Python source code between English and 56 native languages (keywords, builtins, exceptions) and provides keyword lookups, explanation material, identifier validation, and codebase translatability reports — read-only, local, no execution.
Translate code to a native language (
translate_to_native) — converts English-keyword Python into the caller's language; handles files or fragments, pivots through English for non-English pairs, preserves formatting, comments, identifiers, and strings.Translate native code back to English (
translate_to_source) — the inverse, producing interpreter-ready Python for toolchains and upstream collaborators.Verify round trips (
verify_round_tripon both translation tools) — translates back, compares byte-for-byte, checks the canonical form compiles, and reports located divergences by layer (keywords, builtins, exceptions, collisions, etc.).Get explanation material (
explain_in_language) — returns construct-by-construct keyword mappings for the code present plus a compile-only validation result; the calling model writes the prose.Look up keyword mappings (
lookup_keyword_mapping) — filtered lookups for specific English terms or the full dictionary for a language, across keywords, builtins, exceptions, and implicit params.Validate identifier translations (
validate_identifier_translations) — checks proposed identifier renderings for malformed names, unsafe Unicode, reserved terms, drift, and collision against a supplied glossary and the batch; returns conflict-free entries to merge (nothing is written).Map an existing codebase (
map_existing_codebase) — per-file translatability, construct counts, unmapped constructs, and aggregate coverage, optionally including translated files.Version-aware — all tools accept Python 3.10–3.14, defaulting to 3.13.
Safe by design — read-only, non-destructive, no filesystem access, no code execution, no network calls.
Serves as one of the optional translation providers for the language pack system's multi-provider translation API, used to render code and text into a target language.
Acts as one of the selectable translation providers behind the optional multi-provider translation API for translating code artifacts.
Supports self-hostable, local-first machine translation as one of the optional providers for the translation API, keeping data on infrastructure you control.
Allows translation via any OpenAI-compatible endpoint, including models you host yourself, for full LLM-powered translation of identifiers, comments, and strings.
Legesher
Code in Your Native Language - Programming tools that break down the English language barrier
Every package in this repository is Apache-2.0; see Licensing.
About Legesher
Legesher (pronounced "le-GESH-er") enables developers to write code in their native language instead of English.
Imagine writing Python using Spanish keywords like definir instead of def, or Arabic keywords translated the
same way any other language is, with the VS Code translation panel applying right-to-left text direction and
alignment - all while collaborating seamlessly with developers who code in English.
Why Legesher?
The Problem: Programming languages require English keywords, creating a barrier for the 82% of the world's population who don't speak English as their first language. Developers must learn English first before they can code.
The Solution: Legesher translates your code in real-time:
Write code in Spanish, Arabic, or your preferred language
Keep each file in git in the language it was written in: one stored form, so no keyword merge conflicts
Collaborate with developers using any language
Full IDE support with IntelliSense, hover docs, and error messages in your language
What Makes Legesher Different?
Language-Agnostic Git: Each file is stored in the language its author wrote it in. The clean filter keeps a file in that one stored form, so keyword differences never cause merge conflicts, and renderings for a reader come from
legesher translateor, for English files, the editor's Translation Panel, never from a rewrite of the stored file.Real-Time Translation: Bidirectional translation preserves all formatting, comments, and structure.
IDE Integration: A VS Code extension ships today. It talks to a standard Language Server Protocol server, so other LSP-capable editors can drive the same server, though we ship no integration for them yet.
Local-First: Keyword translation happens locally - no cloud required, no data collection. Only the opt-in
--fullLLM translation calls a model, and it can point at one you host yourself.Version-Aware: Language packs adapt automatically to Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Current Status
Pre-beta. Every package here is pre-1.0. For the version a package is on right now, read its
pyproject.toml (or package.json for the VS Code extension); for what changed last, read
CHANGELOG.md.
Languages: 56 supported languages (all experimental, awaiting community validation):
Amharic, Arabic, Bengali, Bosnian, Burmese, Catalan, Chinese, Croatian, Czech, Danish, Dutch, English, Filipino, Finnish, French, Galician, German, Greek, Gujarati, Hebrew, Hindi, Hungarian, Indonesian, Irish, Italian, Japanese, Kannada, Korean, Latvian, Macedonian, Malay, Malayalam, Mongolian, Nepali, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Scottish Gaelic, Serbian, Sinhala, Spanish, Sundanese, Swahili, Swedish, Telugu, Thai, Turkish, Ukrainian, Urdu, Uzbek, Vietnamese, Welsh, Xhosa
Target: Python 3.10-3.14
Translation: Two backends - a pure-stdlib token translator and a Tree-sitter AST translator behind the optional
treesitterextra. Both produce identical outputGit: A clean filter that stores each file in its author's language, and a pre-commit guard
IDE: LSP server with hover, completion, diagnostics, and semantic tokens
VS Code: Extension covering all 56 languages, installed from the VS Code Marketplace
Tests: 200+ test files across the core, i18n, legesher, language-server, mcp, and runtime packages
Related MCP server: DeepL MCP Server
Licensing
Everything in this repository is Apache License 2.0 — the CLI, the translation engine, the language data, the language server, the MCP server, and the editor integrations:
legesher - Main CLI and library
legesher-core - Core translation engine
legesher-i18n - Language data and dictionaries
legesher-language-server - LSP implementation
legesher-mcp - MCP server
legesher-runtime - Localized tracebacks
legesher-vscode - VS Code extension
Use them, modify them, redistribute them — including commercially. Community contributions welcome!
Legesher rewrites your source code and installs a git filter, so being able to read exactly what it does before you run it is the point, not a courtesy.
Legesher is open-core: the paid capabilities live in separate, closed-source codebases, where access is gated by account and API key rather than by a license here. Nothing in this repository requires an account or a network call to work.
See LICENSING.md for the per-package breakdown, or the LICENSE file for the Apache 2.0 terms.
Quick Start in 5 Minutes
Prerequisites
Python 3.10 or higher
uv package manager (recommended) or pip
Installation
# Clone the repository
git clone https://github.com/legesher/legesher.git
cd legesher
# Install dependencies with uv (recommended)
uv sync --all-extras
# Or with pip
pip install -e libs/core -e libs/i18n -e libs/legesherTry Your First Translation
# Create a Python file in Spanish
echo 'definir saludar():
imprimir("¡Hola, mundo!")
saludar()' > hola.py
# Translate to English. --from defaults to en, so name the source language
uv run legesher translate hola.py --from es --to en --output hello.py
# Check the result
cat hello.py
# Output:
# def saludar():
# print("¡Hola, mundo!")
#
# saludar()Keyword translation renames keywords and builtins only. Your own identifiers, such as saludar, stay exactly as
you wrote them. Use --full for LLM-powered translation of identifiers, comments, and strings.
Set Up Git Integration (Optional)
# Initialize Legesher in your repo
uv run legesher git setup --language es
# Git stores each file in its author's language:
# - git add: an English keyword typed into your Spanish file is stored in Spanish
# - git commit: the pre-commit hook runs `legesher guard` on what you stagedIDE Setup (VS Code)
The Legesher VS Code extension is available in pre-beta:
Install the extension from the VS Code Marketplace:
In VS Code: Extensions → search Legesher → Install
Or run
code --install-extension legesher.legesher-vscodeTo use a
.vsixinstead, download it from the latestvscode-vrelease on the releases page, then Extensions → ... menu → Install from VSIX...
Install the language server (hover, completion, diagnostics and keyword highlighting):
pipx install legesher-language-server # or uv tool install legesher-language-serverIf the installer warns that its bin directory is not on your
PATH, runpipx ensurepathoruv tool update-shell, then restart VS Code.legesher-lsphas to be on thePATHVS Code sees, or thelegesher.serverCommandsetting has to hold its full path.Features included:
Language selector with 56 languages
Translation panel (side-by-side view)
Syntax highlighting for translated code
Onboarding flow with language selection
See libs/vs-code/README.md for full documentation.
Next Steps
CONTRIBUTING.md - How to contribute
CHANGELOG.md - What's new
CLAUDE.md - Developer guide for contributors
Features
Core Translation Engine
39 Python Keywords: Complete coverage of Python 3.10-3.14 keywords, including
match/case,except*, andtype73 Built-ins: Built-in functions, types, and constants
70 Exception Classes: Translated exception hierarchy
Two Translation Backends: Token-based (pure stdlib, the default) and Tree-sitter (AST-based, behind the optional
treesitterextra)Round-Trip: EN→ES→EN is byte-identical for the corpus the sweep covers. The known exceptions are listed as strict xfails in
libs/mcp/tests/test_roundtrip_sweep.py, so a fix announces itselfFormat Preservation: Maintains all indentation, blank lines, comments, docstrings
Graceful Degradation: Handles incomplete code and syntax errors
See legesher-core for details.
Language Pack System
56 Languages: Every language listed under Current Status, all at experimental status
Version-Aware: Automatically adapts to Python 3.10, 3.11, 3.12, 3.13, 3.14
Pack Inheritance: Version files inherit from previous versions, minimizing duplication
Translation API: Optional multi-provider translation (Anthropic, Cohere Aya, DeepL, Google, LibreTranslate, and any OpenAI-compatible endpoint)
Validation: Pydantic-based schema validation with Unicode and script-policy checks
CLI Tools: Validate packs, list the registry, export to JSON/CSV
Caching: Thread-safe LRU caching for fast pack loading
See legesher-i18n for details.
Git Integration
The author's form is canonical: the repository stores each file in the language it was written in; the run form Python executes is produced at run time and never replaces the stored file
Keyword normalization at
git add: a stray keyword in another language is rewritten to the file's stored language by the clean filter, which never refuses a fileZero Conflicts: No merge conflicts from keyword differences
Multilingual Teams: one stored file serves a Spanish author and readers in other languages;
legesher translaterenders a copy with keywords, builtins and exceptions in the reader's language (through English between two non-English languages), leaving names, comments and strings as written; the opt-in keyword-only smudge renders an English file's keywords for terminal editorsMetadata Tracking: Privacy-first translation history with audit trail
Atomic Operations: Crash-safe file operations
See legesher-core for git filter documentation.
Three forms of one program
Original (canonical): the form a name's author gave it, in the language they wrote in.
calcular_totalis canonical in a Spanish file, andos.openis canonical because that is what the authors ofoswrote. Git stores this form.Reader view: a rendering for someone who reads in another language, English included.
legesher translateproduces one as a copy; for a file stored in English, the editor's Translation Panel shows a preview-quality one. Neither rewrites the stored file. The opt-in keyword-only smudge is the one rendering that replaces a file's working-tree copy, for English files only, and only when the result cleans back to what git stores.Run form: what CPython executes, with keywords and library names in the form Python defines.
legesher runand the import hook produce it at run time; it never replaces the stored file. The import hook caches it, compiled and with its English source text, beside stock bytecode (__pycache__/<module>.<tag>.legesher-<lang>.pyc).
IDE Support
Language Server Protocol: LSP implementation built on pygls 2.0
Hover Documentation: Translated keyword info and docstrings
Auto-Completion: Localized keyword and builtin completion
Diagnostics: Syntax error reporting with translated messages for English, Spanish, and Arabic
Semantic Tokens: Proper syntax highlighting for translated keywords
VS Code Extension: Onboarding, translation panel, and opt-in telemetry
See legesher-language-server for LSP documentation.
CLI Tools
legesher init: Initialize Legesher in a projectlegesher translate: Translate files or directories (keywords only, or--fullfor LLM-powered full translation)legesher run: Run translated Python files directlylegesher git setup/legesher git status: Configure git integration and inspect itlegesher guard: Refuse Trojan Source characters and keywords out of their stored form (runs on commit)legesher-filter: Git filter (--process,--clean, and the opt-in--smudge), run by git, not by handlegesher metadata: View translation history (show,history,list,raw,validate)legesher config: Read and write project or user configuration (list,get,set)legesher-i18n validate: Validate a language pack filelegesher-i18n registry list: List the shipped packs with their term countslegesher-i18n export: Export packs to JSON or CSV (json,csv,all)
See legesher for CLI documentation.
Versioning Strategy
Legesher uses a hybrid versioning approach with Semantic Versioning:
Foundation Suite (Synchronized)
These packages are released together with the same version:
legesher-core- Core translation enginelegesher-i18n- Language pack infrastructurelegesher- Main CLI package
They share one version number, set in each package's pyproject.toml and bumped together by
release-foundation.yml.
Application Packages (Independent)
These packages each carry their own version number, independent of the foundation suite. Three of them have a release workflow; the fourth is versioned by hand and has no automated release yet:
legesher-vscode- VS Code extension (libs/vs-code/package.json), released byrelease-apps.ymllegesher-mcp- MCP server, taggedmcp-v{version}byrelease-mcp.yml, and apublish-pypi.ymltargetlegesher-language-server- LSP server, taggedlanguage-server-v{version}byrelease-language-server.yml, and apublish-pypi.ymltargetlegesher-runtime- Localized tracebacks, required by thelegesherCLI. No release workflow; apublish-pypi.ymltarget
This lets the apps iterate without waiting on the foundation.
Language Packs (Independent)
56 language packs are released independently, allowing each language community to iterate at their own pace:
legesher-i18n-python-{lang}v0.0.x - Translations for PythonSupported: am, ar, bn, bs, ca, cs, cy, da, de, el, en, es, fa, fi, fr, ga, gd, gl, gu, he, hi, hr, hu, id, it, ja, kn, ko, lv, mk, ml, mn, ms, my, ne, nl, no, pl, pt, ro, ru, si, sr, su, sv, sw, te, th, tl, tr, uk, ur, uz, vi, xh, zh
Each pack supports Python 3.10-3.14 with version-aware inheritance. All packs currently have experimental status, awaiting community validation before being marked as accepted.
For release documentation, see .github/RELEASE_CHECKLIST.md.
Contributing
We welcome contributions! Every package in this repository is Apache-2.0 and accepts them. Please see CONTRIBUTING.md for:
Development setup
Code of Conduct
Contributor License Agreement
Contributors
Available Tools
6 toolsexplain_in_languageARead-onlyIdempotent
Return the engine facts needed to explain code in a language.
Deterministic material only — construct-by-construct keyword mappings for the constructs actually present in the code, and a static (compile-only, never executed) validation result. YOU compose the explanation from these facts; the tool never generates prose, so engine truth stays distinct from narration.
Inputs: source (required), explain_in (required), code_lang, python_version, +1 more. Returns: Engine facts for explaining code — the calling model writes the prose.
lookup_keyword_mappingARead-onlyIdempotent
Look up how specific terms render in a language.
The quick-reference tool: pass English terms for a filtered answer, or omit them for the language's full mapping. For browsing the whole dictionary prefer the legesher://languages/{lang}/terms resource.
Inputs: language (required), terms, python_version. Returns: Keyword-mapping lookup for one language.
map_existing_codebaseARead-onlyIdempotent
Report what translating a codebase into a language would look like.
The legibility report: per-file translatability, construct counts, constructs the target language's pack cannot map yet (they stay English after translation), and an aggregate coverage summary. Orchestrates per-file translate + validate; for a large repo, iterate in batches of files across calls.
Inputs: files (required), target_lang (required), source_lang, python_version, +1 more. Returns: Legibility report: what translating this codebase would look like.
translate_to_nativeARead-onlyIdempotent
Translate Python source code into the caller's natural language.
Accepts complete files and fragments alike — there is no separate
snippet mode to choose. When neither language is English the engine
pivots through English (packs are authored against English) and the
result reports pivoted: true. Formatting, comments, identifiers, and
string contents are preserved; only keywords, builtins, exceptions,
and reserved words are translated.
Inputs: source (required), target_lang (required), source_lang, python_version, +1 more. Returns: Translated source plus the parameters that produced it.
translate_to_sourceARead-onlyIdempotent
Translate native-language code back to English-keyword Python.
The inverse of translate_to_native and the round-trip half of the collaboration story: the output is the form the interpreter, the toolchain, and upstream collaborators use. The target is fixed to English — for a general X→Y translation call translate_to_native with an explicit source_lang.
Inputs: source (required), source_lang (required), python_version, verify_round_trip. Returns: Translated source plus the parameters that produced it.
validate_identifier_translationsARead-onlyIdempotent
Check proposed identifier translations before you record them.
Packs make keywords deterministic; identifiers have no pack, so this is the guarantee they get instead. Each proposal is checked for a name the pack has reserved, for drift (one concept acquiring a second term) and for collision (one term acquiring a second concept) — against both the existing glossary and the rest of the batch.
Returns a verdict per proposal plus accepted, the conflict-free
subset as a mapping ready to merge into the project glossary. Recording
it is the caller's to do: this server writes nothing.
Inputs: proposals (required), target_lang (required), glossary, python_version. Returns: Per-proposal verdicts plus the glossary entries that are safe to record.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly articulated role: two directional translations, a keyword lookup, an identifier validator, a codebase mapping report, and a fact-only explainer. The only mild overlap is between explain_in_language and translate_to_native, since both deal with rendering code in a target language, but the descriptions explicitly separate engine facts from transformed source.
All six names are snake_case and verb-first (translate_*, lookup_*, validate_*, map_*, explain_*), forming a predictable pattern. explain_in_language is the one structural outlier with a prepositional phrase rather than a direct object, but it remains readable and unambiguous.
Six tools is well-matched to a keyword-translation engine: two inverse translations, a lookup, a validator, an aggregate codebase report, and a fact-only explainer. Every tool has a distinct job and nothing feels padded.
The core lifecycle is covered — translate both directions, look up terms, validate identifier choices, and audit a whole codebase. Minor gaps remain: no tool to enumerate available languages/packs (deferred to a resource) and no persistence for glossary writes, which is explicitly the caller's responsibility.
Maintenance
Related MCP Connectors
Translate MCP — LibreTranslate-compatible machine translation.
LibreTranslate MCP — open-source machine translation (BYO endpoint)
iso-codes MCP — lookups against the Debian iso-codes project JSON.
MCP server for Crowdin — projects, files, strings, translation progress, tasks, and members.
Related MCP Servers
- AlicenseBqualityBmaintenanceAn MCP server providing machine translation capabilities via the Lara Translate API, featuring language detection and context-aware translations between numerous language pairs.22552 npm100MIT

DeepL MCP Serverofficial
AlicenseAqualityBmaintenanceA Model Context Protocol server that enables AI assistants to translate and rephrase text between numerous languages using the DeepL API.13625 npm120MIT- AlicenseNot gradedqualityCmaintenanceLocalization as code — push, pull, translate, and extract strings from code with AI. 7 MCP tools for type-safe i18n across 182 languages.121 npm2MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for translating JSON localization files via DeepL API or local LLMs, enabling agents to estimate, check, and run translations.1MIT