Skip to main content

tlate (0.1.0)

Deterministic extract, OCR, apply, and QA plumbing so AI coding agents translate documents across any language pair without ever overwriting source files.

tlate pairs an agentskills.io-compliant Agent Skill (skills/tlate/SKILL.md), a single-source agent ruleset (AGENTS.md) with thin runtime pointers (CLAUDE.md, GEMINI.md, .cursor/rules/tlate.mdc, .github/copilot-instructions.md), and a zero-dependency Python CLI (tlate) so AI agents (Codex, Claude Code, Cursor, Antigravity, GitHub Copilot) translate documents cleanly without writing throwaway parsing scripts. tlate performs no LLM API calls inside the CLI: translation quality depends on the AI agent's chosen model and human review.

Repository: https://github.com/sndiy/tlate

Problem vs. Solution

Problem when AI agents translate files directly How tlate solves it
Agents rewrite fragile extraction/rewriting scripts every session, wasting tokens and breaking formatting. The model only translates segment text; the deterministic tlate CLI handles inspection, extraction, OCR, token protection, rewriting, visual diffing, and QA.
Source files or previous outputs are accidentally overwritten. Every write uses exclusive creation (open(..., "xb")) inside a fresh tlate-output/<stem>_<LANG>_<timestamp>/ folder with SHA-256 verification (tlate verify).
Placeholders ({name}, %1$s), URLs, code spans, or Excel formulas get corrupted. Protected tokens (⟦P1⟧, ⟦S1⟧…⟦/S1⟧) are masked before translation and strictly validated before any output file is written.
Encrypted or DRM-protected files are mishandled. Password-protected PDFs, OLE/RMS Office containers, encrypted ZIPs, and DRM-protected EPUBs are refused upfront (exit code 4, even without optional extras); edit-restricted and signed inputs require explicit acknowledgment (--allow-edit-restricted, --allow-signed), with signatures neutralized + provenance.json recorded. tlate contains zero decryption or DRM-removal code.
Scanned PDFs fail text extraction or force copyleft PDF dependencies everywhere. tlate ocr uses permissive pypdfium2 + pluggable OcrEngine ([ocr] via tesserocr or system tesseract CLI) for per-page text_layer / ocr / mixed routing; PyMuPDF ([pdf]) remains strictly optional.

Quick Start (3 Steps)

# 1. Install from PyPI (Python >= 3.12; zero mandatory core dependencies)
pip install tlate

# Optional extras as needed:
pip install "tlate[office,yaml,compare]"   # DOCX/PPTX/XLSX, YAML, PNG comparison
pip install "tlate[ocr]"                   # Permissive hybrid OCR (pypdfium2 + Pillow + tesserocr>=2.13.0 MIT + local tessdata Apache-2.0)
pip install "tlate[pdf]"                   # Strictly optional PyMuPDF PDF rewrite backend (AGPL-3.0 / Artifex commercial)

# 2. Bootstrap an isolated workspace anywhere (no git clone needed)
tlate setup ./my-translations

# 3. Put files in ./my-translations/documents/ and open the folder in your AI agent

Ask your agent:

Translate documents/guide.docx from English to Japanese (--from en --to ja) using the tlate skill and AGENTS.md. Stop after the glossary and after the pilot for my approval.

Manual CLI flow (--to is required; --from defaults to auto):

tlate init documents/guide.md --from en --to ja
tlate inspect documents/guide.md --to ja --json tlate-output/guide_JA_<timestamp>/reports/inventory.json
tlate extract documents/guide.md --result tlate-output/guide_JA_<timestamp>
# Or for scanned/mixed PDFs:
tlate ocr documents/scan.pdf --result tlate-output/scan_ID_<timestamp> --overlays

tlate batch tlate-output/guide_JA_<timestamp>/work/segments.jsonl --max-tokens 1500
# After translating work/translations/*.jsonl:
tlate apply --result tlate-output/guide_JA_<timestamp>
tlate qa documents/guide.md tlate-output/guide_JA_<timestamp>/output/guide_JA.md --from en --to ja --review-csv tlate-output/guide_JA_<timestamp>/reports/review_sheet.csv
tlate verify tlate-output/guide_JA_<timestamp>

See docs/getting-started.md for installation details, including local editable installs.

Multi-Language & OCR Highlights

  • All languages (--from auto by default; --to required): Any language pair works via languages/ (24 built-in packs verified by tlate lang check) or generic BCP-47 fallback (sv-SE, ks-Arab). Every built-in pack starts at status: "draft" until native-speaker review is recorded, and both draft packs and generic BCP-47 mode emit a stderr warning and list unchecked rules (stopwords, locale typography/quotation/spacing checks, spellcheck, pair-specific expansion overrides, and style-guide rules) in QA reports. See docs/adding-a-language.md.
  • Format-aware language metadata: updates DOCX (w:lang, w:bidi for RTL), PPTX (lang), HTML/EPUB (lang, dir="rtl", <dc:language>), PO (Language, CLDR Plural-Forms), and ARB (@@locale).
  • Adaptive QA & human review sheet: pair-specific length expansion bounds (including compact CJK ratios), language-aware subtitle limits (12 CPS / 18 chars for CJK vs. 17 CPS / 42 chars for Latin/other), stopword/ASCII leftover checks, RTL script validation, and --review-csv / tlate review-sheet (100% of flagged segments + stratified unflagged sample).
  • Permissive hybrid OCR (tlate ocr): per-page classification into text_layer, ocr, or mixed via pypdfium2 + Pillow + tesserocr>=2.13.0 (MIT, requires local tessdata, Apache-2.0) or system tesseract CLI, IoU/coverage deduplication of overlapping OCR boxes, low_ocr_confidence flagging, optional color-coded PNG bounding-box overlays (--overlays), flagged-only cropped previews (--export-crops, 150 DPI, <= 512 px), and explicit white-fill redaction (ocr_overlay_replacement) during tlate apply.
  • Adaptive PDF layout & bookmark preservation: Layout adapts to translated text (font size, wrapping, box size) while preserving the document's structure, within measured metrics, with listed limitations. Page count matches source by default (--allow-extra-pages is strictly opt-in for trailing PDF overflow). See docs/formats/pdf.md and docs/layout-metrics.md.
  • Streaming, safety limits & token efficiency: incremental JSONL streaming (--resume checkpoints), zip-bomb/path-traversal/size/page/segment/pixel guards (--max-file-mb, --max-pages, --max-segments, exit 4), strict --budget-tokens refusal without trimming (exit 7), conservative skip_rules, exact dedup + TM, relevant-only --glossary batch injection, stable-prefix.md, optional --wire-format compact / --fuzzy-tm, tlate pilot, image alt_text round-tripping, and duplicate-consistency QA (tlate qa --result). See docs/efficiency.md.
  • Agent consent & checkpoints: skills/tlate/SKILL.md requires explicit user consent before any network access, model/package download, or writes outside <result>/target workspace, and enforces stops after glossary and pilot.

Visual PDF Comparison (tlate compare)

Actual tlate compare output on a synthetic PDF fixture (preserving colored boxes, raster images, {app_name} placeholders, and URLs):

Side-by-side comparison of source PDF and translated PDF

Supported Formats (Beta)

Format Extensions Status Optional Extra Notes & Docs
Markdown & plain text .md, .markdown, .txt beta (core, stdlib) Preserves fences, tables, BOM/CRLF (docs/formats/markdown-text.md)
Subtitles .srt, .vtt beta (core, stdlib) Keeps cues/timestamps; language-aware line/CPS QA (docs/formats/subtitles.md)
i18n localization .json, .arb, .po, .pot, Android strings.xml beta (core, stdlib) Protects ICU plurals, escapes, CLDR Plural-Forms (docs/formats/i18n.md)
YAML .yaml, .yml beta [yaml] (PyYAML) In-place value edits, comments preserved (docs/formats/i18n.md)
Office OOXML .docx, .pptx, .xlsx beta [office] (lxml) Direct XML; formulas & OLE-encrypted refusal (docs/formats/office.md)
Web & e-book .html, .htm, .xhtml, .epub beta (core, stdlib) Refuses DRM; stores mimetype uncompressed; sets dir="rtl" (docs/formats/html-epub.md)
PDF (text layer) .pdf beta [pdf] (PyMuPDF) Adaptive role-harmonized layout, bookmark translation, risky-layout flags (docs/formats/pdf.md, docs/layout-metrics.md)
PDF (scanned / mixed) .pdf beta [ocr] + [pdf] tlate ocr via pypdfium2 + pluggable OcrEngine (docs/formats/ocr.md)
Planned formats (.doc, .ppt, .xls, .odt, .idml, .ass, Apple .strings) — planned — Not yet supported

Architecture Overview

flowchart LR
  S["Source file<br/>(read-only, SHA-256)"] --> I["tlate init / inspect"]
  I --> E["tlate extract or tlate ocr<br/>+ protect ⟦Pn⟧ / ⟦Sn⟧"]
  E --> B["work/segments.jsonl<br/>+ tlate batch & TM"]
  B --> M["AI Agent / Model<br/>(translates text only)"]
  M --> T["work/translations/*.jsonl"]
  T --> A["tlate apply<br/>(exclusive write xb)"]
  A --> O["output/<stem>_<LANG>.<ext>"]
  O --> Q["tlate qa & compare"]
  O --> V["tlate verify<br/>(SHA-256 check)"]

See docs/architecture.md for the tlate/segments@1 contract, PdfEngine/OcrEngine abstractions, and CLI exit codes (0–7).

License & PyMuPDF Notice

  • This repository is licensed under the MIT License (see LICENSE). The core tlate package has zero mandatory third-party dependencies.
  • The default PDF rewriting backend uses PyMuPDF as an optional extra ([pdf]), never vendored in this repository. PyMuPDF is dual-licensed under GNU AGPL-3.0 or an Artifex commercial license. Users who install, distribute, or run the [pdf] extra (including as a network service) are solely responsible for complying with PyMuPDF's license terms. See THIRD_PARTY_NOTICES.md and docs/security-and-copyright.md.

Honest Limitations

  • Does not guarantee error-free translations. tlate qa is heuristic; manual visual inspection and back-translation sampling remain essential.
  • Scanned/mixed PDF OCR fidelity is lower: original raster fonts, textured/colored backgrounds behind OCR boxes (replaced by solid white fill (1, 1, 1)), kerning, skewed/handwritten text, and complex multi-column tables are not preserved verbatim. See docs/formats/ocr.md.
  • Text inside raster images (non-OCR flows), OOXML chart titles, and SmartArt: not edited automatically.
  • Dense PDF overflow & risky layouts: when translated text still exceeds a box after per-role font sizing, line-height tightening, and collision-free expansion, it is never truncated — tlate renders it in the safest available box and flags overflow_after_adaptive_fit in review_flags (and inspect flags multi_column, text_over_image, rotated_or_vertical_text, form_fields, and fixed_table_cells). Arabic (ar) PDF text extraction emits ToUnicode CMap ligature artifacts (LIMITED_FOR_PDF); see docs/layout-metrics.md.
  • RTL visual verification: tlate sets dir="rtl" / w:bidi and verifies RTL script presence, but bidirectional punctuation/number ordering requires manual visual review.
  • No built-in LLM API client: tlate intentionally contains no translate command that calls remote LLM APIs, keeping document processing strictly local and deterministic; translation quality depends on the AI agent's chosen model and human review.
  • Estimated token budgets & unmeasured provider caching: cost_preview and --budget-tokens use an approximate ~4 chars/token Latin heuristic rather than provider-specific tokenizers; prompt-cache hit rates on stable-prefix.md and multimodal image token costs vary by model/agent and are not measured by tlate. See docs/efficiency.md.
  • Protected files & legal disclaimers: tlate never decrypts password-protected files, never removes DRM, refuses apply on edit-restricted PDFs (to avoid stripping /Encrypt), and never produces certified/sworn legal translations. See docs/protected-files.md for the full detected vs. unhandled list.

Metadata

Release files for tlate 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tlate 0.1.0
File Size Uploaded Provenance Actions
tlate-0.1.0.tar.gz 239.7 kB With provenance Details for tlate-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tlate 0.1.0
File Interpreter ABI Platform Actions
tlate-0.1.0-py3-none-any.whl Python 3 none any Details for tlate-0.1.0-py3-none-any.whl

Total release size: 498.2 kB

Release files / tlate-0.1.0.tar.gz

Download URL tlate-0.1.0.tar.gz
Size 239.7 kB
Tags Source
SHA-256 checksum
How to use checksums
124ce937ee60de9c6cf35b1fd8b04b18f0cf98ade21f1a39f95b5b43865bf46c
BLAKE2b-256 checksum
How to use checksums
e7ddf839f4e5e4ae5305eb78eeb9862db930745ffce852fcf737c946f07b3136
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 Dec 1, 2026.

Transparency log

Release files / tlate-0.1.0-py3-none-any.whl

Download URL tlate-0.1.0-py3-none-any.whl
Size 258.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33c17267b672ec85548c3de2f89283cedce5173930ca0d94dc91b8dc2d0beb1a
BLAKE2b-256 checksum
How to use checksums
7efe3c3938fcaec528a91c50e817dc2632b64540fa5c3754a8bf163cb4e26a8d
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 Dec 1, 2026.

Transparency log

Security for tlate 0.1.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tlate-0.1.0.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 Dec 1, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page