Lesia is an open-source Python library and CLI that automates the translation of LaTeX, Markdown, Typst, MyST, and Jupyter documents — preserving structure, formatting, and syntax while you stay in control.
Built for researchers, scientists, and technical writers who need accurate, structure-preserving translations at scale.
Initialize and manage translation projects with a .translate_dir config file. Track source and target directories per language.
Persistent on-disk cache with checksum-based deduplication. Never pay for the same translation twice β only changed chunks are re-translated.
XML-tagging system protects LaTeX commands, Typst syntax, Markdown fences, and code blocks from being altered during translation.
Cache-aware correction system lets you override specific translations. Your corrections survive subsequent retranslations.
Define domain-specific glossaries to ensure consistent translation of technical terms across your entire project.
Automatically sync non-translatable assets (images, bibliography, fonts) between language directories. Only text changes where it should.
Switch between Google Gemini, OpenAI, Anthropic, xAI, and others. Use a secondary reasoning model for complex passages.
Free access to open-source models via MyDocker (UniversitΓ© Paris-Saclay) and iLaaS β no API key required for Paris-Saclay members.
Embed Lesia into your own scripts and pipelines. Full async support for concurrent translation of multiple files.
From academic papers to data science notebooks, Lesia handles the most popular scientific markup languages.
Lesia breaks the complex translation problem into a reliable, repeatable pipeline.
Documents are split into translatable chunks while preserving document hierarchy.
Commands, code blocks, and special syntax are wrapped in XML tags to protect them from modification.
Each chunk is sent to your configured LLM service with carefully crafted prompts.
Translations are stored with checksums. Identical chunks across files share the same cached result.
Translated chunks are reassembled into complete, valid target documents ready to compile.
Lesia supports major commercial providers as well as self-hosted and institutional deployments.
Install as a standalone CLI tool or embed the library in your own Python project.
# Requires uv (https://docs.astral.sh/uv/) uv tool install lesia # Verify installation lesia --help
# pip pip install lesia # uv uv add lesia
git clone https://github.com/DobbiKov/lesia cd lesia uv sync # Run tests uv run pytest
import asyncio from trans_lib.project_manager import init_project from trans_lib.enums import Language # Initialize project project = init_project("my_project", "/path/to/root") # Configure source project.set_source_directory("docs_fr", Language.FRENCH) project.add_target_language(Language.ENGLISH) project.set_file_translatability("docs_fr/main.tex", True) # Sync static assets and translate project.sync_untranslatable_files() asyncio.run(project.translate_single_file( "docs_fr/main.tex", Language.ENGLISH, None ))
Translate between any combination of the supported natural languages.
Using Lesia in your research? Please cite it as follows.