tlate 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. tlate-0.1.0/LICENSE +21 -0
  2. tlate-0.1.0/PKG-INFO +172 -0
  3. tlate-0.1.0/README.md +125 -0
  4. tlate-0.1.0/THIRD_PARTY_NOTICES.md +85 -0
  5. tlate-0.1.0/pyproject.toml +78 -0
  6. tlate-0.1.0/setup.cfg +4 -0
  7. tlate-0.1.0/src/tlate/__init__.py +8 -0
  8. tlate-0.1.0/src/tlate/__main__.py +3 -0
  9. tlate-0.1.0/src/tlate/checkpoint.py +155 -0
  10. tlate-0.1.0/src/tlate/cli.py +1358 -0
  11. tlate-0.1.0/src/tlate/compare.py +126 -0
  12. tlate-0.1.0/src/tlate/errors.py +71 -0
  13. tlate-0.1.0/src/tlate/formats/__init__.py +67 -0
  14. tlate-0.1.0/src/tlate/formats/androidxml.py +162 -0
  15. tlate-0.1.0/src/tlate/formats/base.py +100 -0
  16. tlate-0.1.0/src/tlate/formats/epub.py +136 -0
  17. tlate-0.1.0/src/tlate/formats/html.py +180 -0
  18. tlate-0.1.0/src/tlate/formats/jsonfmt.py +196 -0
  19. tlate-0.1.0/src/tlate/formats/markdown.py +242 -0
  20. tlate-0.1.0/src/tlate/formats/ooxml.py +681 -0
  21. tlate-0.1.0/src/tlate/formats/pdf.py +148 -0
  22. tlate-0.1.0/src/tlate/formats/plaintext.py +136 -0
  23. tlate-0.1.0/src/tlate/formats/po.py +202 -0
  24. tlate-0.1.0/src/tlate/formats/subtitles.py +276 -0
  25. tlate-0.1.0/src/tlate/formats/textdoc.py +131 -0
  26. tlate-0.1.0/src/tlate/formats/yamlfmt.py +100 -0
  27. tlate-0.1.0/src/tlate/glossary.py +124 -0
  28. tlate-0.1.0/src/tlate/images.py +478 -0
  29. tlate-0.1.0/src/tlate/kit_data/AGENTS.md +129 -0
  30. tlate-0.1.0/src/tlate/kit_data/CLAUDE.md +3 -0
  31. tlate-0.1.0/src/tlate/kit_data/GEMINI.md +4 -0
  32. tlate-0.1.0/src/tlate/kit_data/dot_cursor/rules/tlate.mdc +7 -0
  33. tlate-0.1.0/src/tlate/kit_data/dot_github/copilot-instructions.md +4 -0
  34. tlate-0.1.0/src/tlate/kit_data/skills/tlate/SKILL.md +209 -0
  35. tlate-0.1.0/src/tlate/kit_data/skills/tlate/assets/glossary-template.md +23 -0
  36. tlate-0.1.0/src/tlate/kit_data/skills/tlate/references/layout-by-format.md +144 -0
  37. tlate-0.1.0/src/tlate/kit_data/skills/tlate/references/qa-checklist.md +45 -0
  38. tlate-0.1.0/src/tlate/kit_data/skills/tlate/references/style-guides/default.md +27 -0
  39. tlate-0.1.0/src/tlate/languages.py +561 -0
  40. tlate-0.1.0/src/tlate/languages_data/ar/glossary-template.md +23 -0
  41. tlate-0.1.0/src/tlate/languages_data/ar/pack.json +92 -0
  42. tlate-0.1.0/src/tlate/languages_data/ar/style-guide.md +18 -0
  43. tlate-0.1.0/src/tlate/languages_data/de/glossary-template.md +23 -0
  44. tlate-0.1.0/src/tlate/languages_data/de/pack.json +105 -0
  45. tlate-0.1.0/src/tlate/languages_data/de/style-guide.md +23 -0
  46. tlate-0.1.0/src/tlate/languages_data/en/glossary-template.md +23 -0
  47. tlate-0.1.0/src/tlate/languages_data/en/pack.json +162 -0
  48. tlate-0.1.0/src/tlate/languages_data/en/style-guide.md +25 -0
  49. tlate-0.1.0/src/tlate/languages_data/es/glossary-template.md +23 -0
  50. tlate-0.1.0/src/tlate/languages_data/es/pack.json +110 -0
  51. tlate-0.1.0/src/tlate/languages_data/es/style-guide.md +25 -0
  52. tlate-0.1.0/src/tlate/languages_data/fa/glossary-template.md +23 -0
  53. tlate-0.1.0/src/tlate/languages_data/fa/pack.json +87 -0
  54. tlate-0.1.0/src/tlate/languages_data/fa/style-guide.md +28 -0
  55. tlate-0.1.0/src/tlate/languages_data/fr/glossary-template.md +23 -0
  56. tlate-0.1.0/src/tlate/languages_data/fr/pack.json +107 -0
  57. tlate-0.1.0/src/tlate/languages_data/fr/style-guide.md +25 -0
  58. tlate-0.1.0/src/tlate/languages_data/he/glossary-template.md +23 -0
  59. tlate-0.1.0/src/tlate/languages_data/he/pack.json +87 -0
  60. tlate-0.1.0/src/tlate/languages_data/he/style-guide.md +28 -0
  61. tlate-0.1.0/src/tlate/languages_data/hi/glossary-template.md +23 -0
  62. tlate-0.1.0/src/tlate/languages_data/hi/pack.json +81 -0
  63. tlate-0.1.0/src/tlate/languages_data/hi/style-guide.md +25 -0
  64. tlate-0.1.0/src/tlate/languages_data/id/glossary-template.md +23 -0
  65. tlate-0.1.0/src/tlate/languages_data/id/pack.json +115 -0
  66. tlate-0.1.0/src/tlate/languages_data/id/style-guide.md +45 -0
  67. tlate-0.1.0/src/tlate/languages_data/it/glossary-template.md +23 -0
  68. tlate-0.1.0/src/tlate/languages_data/it/pack.json +97 -0
  69. tlate-0.1.0/src/tlate/languages_data/it/style-guide.md +25 -0
  70. tlate-0.1.0/src/tlate/languages_data/ja/glossary-template.md +23 -0
  71. tlate-0.1.0/src/tlate/languages_data/ja/pack.json +84 -0
  72. tlate-0.1.0/src/tlate/languages_data/ja/style-guide.md +23 -0
  73. tlate-0.1.0/src/tlate/languages_data/ko/glossary-template.md +23 -0
  74. tlate-0.1.0/src/tlate/languages_data/ko/pack.json +84 -0
  75. tlate-0.1.0/src/tlate/languages_data/ko/style-guide.md +25 -0
  76. tlate-0.1.0/src/tlate/languages_data/nl/glossary-template.md +23 -0
  77. tlate-0.1.0/src/tlate/languages_data/nl/pack.json +95 -0
  78. tlate-0.1.0/src/tlate/languages_data/nl/style-guide.md +25 -0
  79. tlate-0.1.0/src/tlate/languages_data/pl/glossary-template.md +23 -0
  80. tlate-0.1.0/src/tlate/languages_data/pl/pack.json +91 -0
  81. tlate-0.1.0/src/tlate/languages_data/pl/style-guide.md +25 -0
  82. tlate-0.1.0/src/tlate/languages_data/pt/glossary-template.md +23 -0
  83. tlate-0.1.0/src/tlate/languages_data/pt/pack.json +106 -0
  84. tlate-0.1.0/src/tlate/languages_data/pt/style-guide.md +25 -0
  85. tlate-0.1.0/src/tlate/languages_data/pt-BR/glossary-template.md +23 -0
  86. tlate-0.1.0/src/tlate/languages_data/pt-BR/pack.json +106 -0
  87. tlate-0.1.0/src/tlate/languages_data/pt-BR/style-guide.md +25 -0
  88. tlate-0.1.0/src/tlate/languages_data/ru/glossary-template.md +23 -0
  89. tlate-0.1.0/src/tlate/languages_data/ru/pack.json +106 -0
  90. tlate-0.1.0/src/tlate/languages_data/ru/style-guide.md +25 -0
  91. tlate-0.1.0/src/tlate/languages_data/th/glossary-template.md +23 -0
  92. tlate-0.1.0/src/tlate/languages_data/th/pack.json +66 -0
  93. tlate-0.1.0/src/tlate/languages_data/th/style-guide.md +28 -0
  94. tlate-0.1.0/src/tlate/languages_data/tr/glossary-template.md +23 -0
  95. tlate-0.1.0/src/tlate/languages_data/tr/pack.json +91 -0
  96. tlate-0.1.0/src/tlate/languages_data/tr/style-guide.md +25 -0
  97. tlate-0.1.0/src/tlate/languages_data/ur/glossary-template.md +23 -0
  98. tlate-0.1.0/src/tlate/languages_data/ur/pack.json +87 -0
  99. tlate-0.1.0/src/tlate/languages_data/ur/style-guide.md +28 -0
  100. tlate-0.1.0/src/tlate/languages_data/vi/glossary-template.md +23 -0
  101. tlate-0.1.0/src/tlate/languages_data/vi/pack.json +95 -0
  102. tlate-0.1.0/src/tlate/languages_data/vi/style-guide.md +25 -0
  103. tlate-0.1.0/src/tlate/languages_data/zh/glossary-template.md +23 -0
  104. tlate-0.1.0/src/tlate/languages_data/zh/pack.json +84 -0
  105. tlate-0.1.0/src/tlate/languages_data/zh/style-guide.md +28 -0
  106. tlate-0.1.0/src/tlate/languages_data/zh-Hans/glossary-template.md +23 -0
  107. tlate-0.1.0/src/tlate/languages_data/zh-Hans/pack.json +84 -0
  108. tlate-0.1.0/src/tlate/languages_data/zh-Hans/style-guide.md +28 -0
  109. tlate-0.1.0/src/tlate/languages_data/zh-Hant/glossary-template.md +23 -0
  110. tlate-0.1.0/src/tlate/languages_data/zh-Hant/pack.json +84 -0
  111. tlate-0.1.0/src/tlate/languages_data/zh-Hant/style-guide.md +28 -0
  112. tlate-0.1.0/src/tlate/limits.py +198 -0
  113. tlate-0.1.0/src/tlate/memory.py +530 -0
  114. tlate-0.1.0/src/tlate/ocr/__init__.py +28 -0
  115. tlate-0.1.0/src/tlate/ocr/engines.py +496 -0
  116. tlate-0.1.0/src/tlate/ocr/pipeline.py +520 -0
  117. tlate-0.1.0/src/tlate/ocr/render.py +294 -0
  118. tlate-0.1.0/src/tlate/ocr/types.py +40 -0
  119. tlate-0.1.0/src/tlate/pdf/__init__.py +137 -0
  120. tlate-0.1.0/src/tlate/pdf/fonts.py +244 -0
  121. tlate-0.1.0/src/tlate/pdf/layout.py +309 -0
  122. tlate-0.1.0/src/tlate/pdf/metrics.py +801 -0
  123. tlate-0.1.0/src/tlate/pdf/pymupdf_engine.py +1053 -0
  124. tlate-0.1.0/src/tlate/pipeline.py +438 -0
  125. tlate-0.1.0/src/tlate/protect.py +243 -0
  126. tlate-0.1.0/src/tlate/protection.py +1030 -0
  127. tlate-0.1.0/src/tlate/qa.py +833 -0
  128. tlate-0.1.0/src/tlate/safety.py +212 -0
  129. tlate-0.1.0/src/tlate/segments.py +257 -0
  130. tlate-0.1.0/src/tlate/setup_ws.py +64 -0
  131. tlate-0.1.0/src/tlate/skip_rules.py +222 -0
  132. tlate-0.1.0/src/tlate.egg-info/PKG-INFO +172 -0
  133. tlate-0.1.0/src/tlate.egg-info/SOURCES.txt +156 -0
  134. tlate-0.1.0/src/tlate.egg-info/dependency_links.txt +1 -0
  135. tlate-0.1.0/src/tlate.egg-info/entry_points.txt +2 -0
  136. tlate-0.1.0/src/tlate.egg-info/requires.txt +31 -0
  137. tlate-0.1.0/src/tlate.egg-info/top_level.txt +1 -0
  138. tlate-0.1.0/tests/test_cli_core.py +153 -0
  139. tlate-0.1.0/tests/test_efficiency.py +688 -0
  140. tlate-0.1.0/tests/test_evals.py +21 -0
  141. tlate-0.1.0/tests/test_format_html_epub.py +97 -0
  142. tlate-0.1.0/tests/test_format_i18n.py +104 -0
  143. tlate-0.1.0/tests/test_format_ooxml.py +132 -0
  144. tlate-0.1.0/tests/test_format_pdf.py +267 -0
  145. tlate-0.1.0/tests/test_format_subtitles.py +64 -0
  146. tlate-0.1.0/tests/test_format_text.py +96 -0
  147. tlate-0.1.0/tests/test_limits.py +208 -0
  148. tlate-0.1.0/tests/test_multilang.py +532 -0
  149. tlate-0.1.0/tests/test_ocr.py +459 -0
  150. tlate-0.1.0/tests/test_p3b_step1.py +378 -0
  151. tlate-0.1.0/tests/test_pdf_adaptive_layout.py +488 -0
  152. tlate-0.1.0/tests/test_pdf_layout.py +382 -0
  153. tlate-0.1.0/tests/test_protect.py +67 -0
  154. tlate-0.1.0/tests/test_protection.py +688 -0
  155. tlate-0.1.0/tests/test_repo_checks.py +184 -0
  156. tlate-0.1.0/tests/test_safety.py +193 -0
  157. tlate-0.1.0/tests/test_setup.py +53 -0
  158. tlate-0.1.0/tests/test_validate_skill.py +195 -0
tlate-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sendy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
tlate-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.4
2
+ Name: tlate
3
+ Version: 0.1.0
4
+ Summary: Deterministic extract/apply/QA engine so AI agents translate documents across languages without overwriting sources.
5
+ Author: Sendy
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/sndiy/tlate
8
+ Project-URL: Repository, https://github.com/sndiy/tlate
9
+ Project-URL: Issues, https://github.com/sndiy/tlate/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Programming Language :: Python :: 3.15
17
+ Classifier: Topic :: Text Processing :: Linguistic
18
+ Requires-Python: >=3.12
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ License-File: THIRD_PARTY_NOTICES.md
22
+ Provides-Extra: office
23
+ Requires-Dist: lxml>=6.0; extra == "office"
24
+ Provides-Extra: yaml
25
+ Requires-Dist: PyYAML>=6.0.2; extra == "yaml"
26
+ Provides-Extra: pdf
27
+ Requires-Dist: pymupdf>=1.28.2; extra == "pdf"
28
+ Provides-Extra: compare
29
+ Requires-Dist: Pillow>=12.0; extra == "compare"
30
+ Provides-Extra: ocr
31
+ Requires-Dist: pypdfium2>=5.0; extra == "ocr"
32
+ Requires-Dist: Pillow>=12.0; extra == "ocr"
33
+ Requires-Dist: tesserocr>=2.13.0; extra == "ocr"
34
+ Provides-Extra: all
35
+ Requires-Dist: lxml>=6.0; extra == "all"
36
+ Requires-Dist: PyYAML>=6.0.2; extra == "all"
37
+ Requires-Dist: pymupdf>=1.28.2; extra == "all"
38
+ Requires-Dist: Pillow>=12.0; extra == "all"
39
+ Provides-Extra: dev
40
+ Requires-Dist: pytest>=9.0; extra == "dev"
41
+ Requires-Dist: ruff>=0.14; extra == "dev"
42
+ Requires-Dist: lxml>=6.0; extra == "dev"
43
+ Requires-Dist: PyYAML>=6.0.2; extra == "dev"
44
+ Requires-Dist: Pillow>=12.0; extra == "dev"
45
+ Requires-Dist: pypdfium2>=5.0; extra == "dev"
46
+ Dynamic: license-file
47
+
48
+ # tlate (`0.1.0`)
49
+
50
+ **Deterministic extract, OCR, apply, and QA plumbing so AI coding agents translate documents across any language pair without ever overwriting source files.**
51
+
52
+ `tlate` pairs an `agentskills.io`-compliant Agent Skill ([skills/tlate/SKILL.md](skills/tlate/SKILL.md)), a single-source agent ruleset ([AGENTS.md](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.
53
+
54
+ Repository: https://github.com/sndiy/tlate
55
+
56
+ ## Problem vs. Solution
57
+
58
+ | Problem when AI agents translate files directly | How `tlate` solves it |
59
+ |---|---|
60
+ | 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. |
61
+ | 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`). |
62
+ | 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. |
63
+ | 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. |
64
+ | 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. |
65
+
66
+ ## Quick Start (3 Steps)
67
+
68
+ ```bash
69
+ # 1. Install from PyPI (Python >= 3.12; zero mandatory core dependencies)
70
+ pip install tlate
71
+
72
+ # Optional extras as needed:
73
+ pip install "tlate[office,yaml,compare]" # DOCX/PPTX/XLSX, YAML, PNG comparison
74
+ pip install "tlate[ocr]" # Permissive hybrid OCR (pypdfium2 + Pillow + tesserocr>=2.13.0 MIT + local tessdata Apache-2.0)
75
+ pip install "tlate[pdf]" # Strictly optional PyMuPDF PDF rewrite backend (AGPL-3.0 / Artifex commercial)
76
+
77
+ # 2. Bootstrap an isolated workspace anywhere (no git clone needed)
78
+ tlate setup ./my-translations
79
+
80
+ # 3. Put files in ./my-translations/documents/ and open the folder in your AI agent
81
+ ```
82
+
83
+ Ask your agent:
84
+ > 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.
85
+
86
+ Manual CLI flow (`--to` is required; `--from` defaults to `auto`):
87
+ ```bash
88
+ tlate init documents/guide.md --from en --to ja
89
+ tlate inspect documents/guide.md --to ja --json tlate-output/guide_JA_<timestamp>/reports/inventory.json
90
+ tlate extract documents/guide.md --result tlate-output/guide_JA_<timestamp>
91
+ # Or for scanned/mixed PDFs:
92
+ tlate ocr documents/scan.pdf --result tlate-output/scan_ID_<timestamp> --overlays
93
+
94
+ tlate batch tlate-output/guide_JA_<timestamp>/work/segments.jsonl --max-tokens 1500
95
+ # After translating work/translations/*.jsonl:
96
+ tlate apply --result tlate-output/guide_JA_<timestamp>
97
+ 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
98
+ tlate verify tlate-output/guide_JA_<timestamp>
99
+ ```
100
+
101
+ See [docs/getting-started.md](docs/getting-started.md) for installation details, including local editable installs.
102
+
103
+ ## Multi-Language & OCR Highlights
104
+
105
+ - **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](docs/adding-a-language.md).
106
+ - **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`).
107
+ - **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).
108
+ - **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`.
109
+ - **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](docs/formats/pdf.md) and [docs/layout-metrics.md](docs/layout-metrics.md).
110
+ - **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](docs/efficiency.md).
111
+ - **Agent consent & checkpoints:** [skills/tlate/SKILL.md](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.
112
+
113
+ ### Visual PDF Comparison (`tlate compare`)
114
+
115
+ Actual `tlate compare` output on a synthetic PDF fixture (preserving colored boxes, raster images, `{app_name}` placeholders, and URLs):
116
+
117
+ ![Side-by-side comparison of source PDF and translated PDF](docs/demo/pdf-compare.png)
118
+
119
+ ## Supported Formats (Beta)
120
+
121
+ | Format | Extensions | Status | Optional Extra | Notes & Docs |
122
+ |---|---|---|---|---|
123
+ | Markdown & plain text | `.md`, `.markdown`, `.txt` | **beta** | *(core, stdlib)* | Preserves fences, tables, BOM/CRLF ([docs/formats/markdown-text.md](docs/formats/markdown-text.md)) |
124
+ | Subtitles | `.srt`, `.vtt` | **beta** | *(core, stdlib)* | Keeps cues/timestamps; language-aware line/CPS QA ([docs/formats/subtitles.md](docs/formats/subtitles.md)) |
125
+ | i18n localization | `.json`, `.arb`, `.po`, `.pot`, Android `strings.xml` | **beta** | *(core, stdlib)* | Protects ICU plurals, escapes, CLDR `Plural-Forms` ([docs/formats/i18n.md](docs/formats/i18n.md)) |
126
+ | YAML | `.yaml`, `.yml` | **beta** | `[yaml]` (PyYAML) | In-place value edits, comments preserved ([docs/formats/i18n.md](docs/formats/i18n.md)) |
127
+ | Office OOXML | `.docx`, `.pptx`, `.xlsx` | **beta** | `[office]` (lxml) | Direct XML; formulas & OLE-encrypted refusal ([docs/formats/office.md](docs/formats/office.md)) |
128
+ | Web & e-book | `.html`, `.htm`, `.xhtml`, `.epub` | **beta** | *(core, stdlib)* | Refuses DRM; stores `mimetype` uncompressed; sets `dir="rtl"` ([docs/formats/html-epub.md](docs/formats/html-epub.md)) |
129
+ | PDF (text layer) | `.pdf` | **beta** | `[pdf]` (PyMuPDF) | Adaptive role-harmonized layout, bookmark translation, risky-layout flags ([docs/formats/pdf.md](docs/formats/pdf.md), [docs/layout-metrics.md](docs/layout-metrics.md)) |
130
+ | PDF (scanned / mixed) | `.pdf` | **beta** | `[ocr]` + `[pdf]` | `tlate ocr` via `pypdfium2` + pluggable `OcrEngine` ([docs/formats/ocr.md](docs/formats/ocr.md)) |
131
+ | Planned formats (`.doc`, `.ppt`, `.xls`, `.odt`, `.idml`, `.ass`, Apple `.strings`) | — | **planned** | — | Not yet supported |
132
+
133
+ ## Architecture Overview
134
+
135
+ ```mermaid
136
+ flowchart LR
137
+ S["Source file<br/>(read-only, SHA-256)"] --> I["tlate init / inspect"]
138
+ I --> E["tlate extract or tlate ocr<br/>+ protect ⟦Pn⟧ / ⟦Sn⟧"]
139
+ E --> B["work/segments.jsonl<br/>+ tlate batch & TM"]
140
+ B --> M["AI Agent / Model<br/>(translates text only)"]
141
+ M --> T["work/translations/*.jsonl"]
142
+ T --> A["tlate apply<br/>(exclusive write xb)"]
143
+ A --> O["output/<stem>_<LANG>.<ext>"]
144
+ O --> Q["tlate qa & compare"]
145
+ O --> V["tlate verify<br/>(SHA-256 check)"]
146
+ ```
147
+
148
+ See [docs/architecture.md](docs/architecture.md) for the `tlate/segments@1` contract, `PdfEngine`/`OcrEngine` abstractions, and CLI exit codes (`0`–`7`).
149
+
150
+ ## License & PyMuPDF Notice
151
+
152
+ - This repository is licensed under the **MIT License** (see [LICENSE](LICENSE)). The core `tlate` package has **zero mandatory third-party dependencies**.
153
+ - 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](THIRD_PARTY_NOTICES.md) and [docs/security-and-copyright.md](docs/security-and-copyright.md).
154
+
155
+ ## Honest Limitations
156
+
157
+ - **Does not guarantee error-free translations.** `tlate qa` is heuristic; manual visual inspection and back-translation sampling remain essential.
158
+ - **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](docs/formats/ocr.md).
159
+ - **Text inside raster images (non-OCR flows), OOXML chart titles, and SmartArt:** not edited automatically.
160
+ - **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](docs/layout-metrics.md).
161
+ - **RTL visual verification:** `tlate` sets `dir="rtl"` / `w:bidi` and verifies RTL script presence, but bidirectional punctuation/number ordering requires manual visual review.
162
+ - **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.
163
+ - **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](docs/efficiency.md).
164
+ - **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](docs/protected-files.md) for the full detected vs. unhandled list.
165
+
166
+ ## Related Documentation
167
+
168
+ - [Getting Started](docs/getting-started.md) · [Architecture](docs/architecture.md) · [Glossary Guide](docs/glossary-howto.md)
169
+ - [Adding a Language Pack](docs/adding-a-language.md) · [Indonesian Pack Guide](languages/id/style-guide.md) · [QA Guide](docs/qa.md) · [Troubleshooting](docs/troubleshooting.md)
170
+ - [Evaluations (33/33)](docs/evals.md) · [PDF Layout Metrics](docs/layout-metrics.md) · [Efficiency & Benchmarks](docs/efficiency.md) · [Known Issues](docs/known-issues.md)
171
+ - [Security, Privacy & Licensing](docs/security-and-copyright.md) · [Protected Files](docs/protected-files.md) · [Password Mode Design](docs/design-password-mode.md) · [Python Support](docs/python-support.md) · [Dependencies Audit](docs/dependencies.md) · [Claims Map](docs/claims.md) · [Credits](docs/credits.md)
172
+ - [Contributing](CONTRIBUTING.md) · [Code of Conduct](CODE_OF_CONDUCT.md) · [Security Policy](SECURITY.md) · [Changelog](CHANGELOG.md)
tlate-0.1.0/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # tlate (`0.1.0`)
2
+
3
+ **Deterministic extract, OCR, apply, and QA plumbing so AI coding agents translate documents across any language pair without ever overwriting source files.**
4
+
5
+ `tlate` pairs an `agentskills.io`-compliant Agent Skill ([skills/tlate/SKILL.md](skills/tlate/SKILL.md)), a single-source agent ruleset ([AGENTS.md](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.
6
+
7
+ Repository: https://github.com/sndiy/tlate
8
+
9
+ ## Problem vs. Solution
10
+
11
+ | Problem when AI agents translate files directly | How `tlate` solves it |
12
+ |---|---|
13
+ | 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. |
14
+ | 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`). |
15
+ | 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. |
16
+ | 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. |
17
+ | 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. |
18
+
19
+ ## Quick Start (3 Steps)
20
+
21
+ ```bash
22
+ # 1. Install from PyPI (Python >= 3.12; zero mandatory core dependencies)
23
+ pip install tlate
24
+
25
+ # Optional extras as needed:
26
+ pip install "tlate[office,yaml,compare]" # DOCX/PPTX/XLSX, YAML, PNG comparison
27
+ pip install "tlate[ocr]" # Permissive hybrid OCR (pypdfium2 + Pillow + tesserocr>=2.13.0 MIT + local tessdata Apache-2.0)
28
+ pip install "tlate[pdf]" # Strictly optional PyMuPDF PDF rewrite backend (AGPL-3.0 / Artifex commercial)
29
+
30
+ # 2. Bootstrap an isolated workspace anywhere (no git clone needed)
31
+ tlate setup ./my-translations
32
+
33
+ # 3. Put files in ./my-translations/documents/ and open the folder in your AI agent
34
+ ```
35
+
36
+ Ask your agent:
37
+ > 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.
38
+
39
+ Manual CLI flow (`--to` is required; `--from` defaults to `auto`):
40
+ ```bash
41
+ tlate init documents/guide.md --from en --to ja
42
+ tlate inspect documents/guide.md --to ja --json tlate-output/guide_JA_<timestamp>/reports/inventory.json
43
+ tlate extract documents/guide.md --result tlate-output/guide_JA_<timestamp>
44
+ # Or for scanned/mixed PDFs:
45
+ tlate ocr documents/scan.pdf --result tlate-output/scan_ID_<timestamp> --overlays
46
+
47
+ tlate batch tlate-output/guide_JA_<timestamp>/work/segments.jsonl --max-tokens 1500
48
+ # After translating work/translations/*.jsonl:
49
+ tlate apply --result tlate-output/guide_JA_<timestamp>
50
+ 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
51
+ tlate verify tlate-output/guide_JA_<timestamp>
52
+ ```
53
+
54
+ See [docs/getting-started.md](docs/getting-started.md) for installation details, including local editable installs.
55
+
56
+ ## Multi-Language & OCR Highlights
57
+
58
+ - **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](docs/adding-a-language.md).
59
+ - **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`).
60
+ - **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).
61
+ - **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`.
62
+ - **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](docs/formats/pdf.md) and [docs/layout-metrics.md](docs/layout-metrics.md).
63
+ - **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](docs/efficiency.md).
64
+ - **Agent consent & checkpoints:** [skills/tlate/SKILL.md](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.
65
+
66
+ ### Visual PDF Comparison (`tlate compare`)
67
+
68
+ Actual `tlate compare` output on a synthetic PDF fixture (preserving colored boxes, raster images, `{app_name}` placeholders, and URLs):
69
+
70
+ ![Side-by-side comparison of source PDF and translated PDF](docs/demo/pdf-compare.png)
71
+
72
+ ## Supported Formats (Beta)
73
+
74
+ | Format | Extensions | Status | Optional Extra | Notes & Docs |
75
+ |---|---|---|---|---|
76
+ | Markdown & plain text | `.md`, `.markdown`, `.txt` | **beta** | *(core, stdlib)* | Preserves fences, tables, BOM/CRLF ([docs/formats/markdown-text.md](docs/formats/markdown-text.md)) |
77
+ | Subtitles | `.srt`, `.vtt` | **beta** | *(core, stdlib)* | Keeps cues/timestamps; language-aware line/CPS QA ([docs/formats/subtitles.md](docs/formats/subtitles.md)) |
78
+ | i18n localization | `.json`, `.arb`, `.po`, `.pot`, Android `strings.xml` | **beta** | *(core, stdlib)* | Protects ICU plurals, escapes, CLDR `Plural-Forms` ([docs/formats/i18n.md](docs/formats/i18n.md)) |
79
+ | YAML | `.yaml`, `.yml` | **beta** | `[yaml]` (PyYAML) | In-place value edits, comments preserved ([docs/formats/i18n.md](docs/formats/i18n.md)) |
80
+ | Office OOXML | `.docx`, `.pptx`, `.xlsx` | **beta** | `[office]` (lxml) | Direct XML; formulas & OLE-encrypted refusal ([docs/formats/office.md](docs/formats/office.md)) |
81
+ | Web & e-book | `.html`, `.htm`, `.xhtml`, `.epub` | **beta** | *(core, stdlib)* | Refuses DRM; stores `mimetype` uncompressed; sets `dir="rtl"` ([docs/formats/html-epub.md](docs/formats/html-epub.md)) |
82
+ | PDF (text layer) | `.pdf` | **beta** | `[pdf]` (PyMuPDF) | Adaptive role-harmonized layout, bookmark translation, risky-layout flags ([docs/formats/pdf.md](docs/formats/pdf.md), [docs/layout-metrics.md](docs/layout-metrics.md)) |
83
+ | PDF (scanned / mixed) | `.pdf` | **beta** | `[ocr]` + `[pdf]` | `tlate ocr` via `pypdfium2` + pluggable `OcrEngine` ([docs/formats/ocr.md](docs/formats/ocr.md)) |
84
+ | Planned formats (`.doc`, `.ppt`, `.xls`, `.odt`, `.idml`, `.ass`, Apple `.strings`) | — | **planned** | — | Not yet supported |
85
+
86
+ ## Architecture Overview
87
+
88
+ ```mermaid
89
+ flowchart LR
90
+ S["Source file<br/>(read-only, SHA-256)"] --> I["tlate init / inspect"]
91
+ I --> E["tlate extract or tlate ocr<br/>+ protect ⟦Pn⟧ / ⟦Sn⟧"]
92
+ E --> B["work/segments.jsonl<br/>+ tlate batch & TM"]
93
+ B --> M["AI Agent / Model<br/>(translates text only)"]
94
+ M --> T["work/translations/*.jsonl"]
95
+ T --> A["tlate apply<br/>(exclusive write xb)"]
96
+ A --> O["output/<stem>_<LANG>.<ext>"]
97
+ O --> Q["tlate qa & compare"]
98
+ O --> V["tlate verify<br/>(SHA-256 check)"]
99
+ ```
100
+
101
+ See [docs/architecture.md](docs/architecture.md) for the `tlate/segments@1` contract, `PdfEngine`/`OcrEngine` abstractions, and CLI exit codes (`0`–`7`).
102
+
103
+ ## License & PyMuPDF Notice
104
+
105
+ - This repository is licensed under the **MIT License** (see [LICENSE](LICENSE)). The core `tlate` package has **zero mandatory third-party dependencies**.
106
+ - 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](THIRD_PARTY_NOTICES.md) and [docs/security-and-copyright.md](docs/security-and-copyright.md).
107
+
108
+ ## Honest Limitations
109
+
110
+ - **Does not guarantee error-free translations.** `tlate qa` is heuristic; manual visual inspection and back-translation sampling remain essential.
111
+ - **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](docs/formats/ocr.md).
112
+ - **Text inside raster images (non-OCR flows), OOXML chart titles, and SmartArt:** not edited automatically.
113
+ - **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](docs/layout-metrics.md).
114
+ - **RTL visual verification:** `tlate` sets `dir="rtl"` / `w:bidi` and verifies RTL script presence, but bidirectional punctuation/number ordering requires manual visual review.
115
+ - **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.
116
+ - **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](docs/efficiency.md).
117
+ - **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](docs/protected-files.md) for the full detected vs. unhandled list.
118
+
119
+ ## Related Documentation
120
+
121
+ - [Getting Started](docs/getting-started.md) · [Architecture](docs/architecture.md) · [Glossary Guide](docs/glossary-howto.md)
122
+ - [Adding a Language Pack](docs/adding-a-language.md) · [Indonesian Pack Guide](languages/id/style-guide.md) · [QA Guide](docs/qa.md) · [Troubleshooting](docs/troubleshooting.md)
123
+ - [Evaluations (33/33)](docs/evals.md) · [PDF Layout Metrics](docs/layout-metrics.md) · [Efficiency & Benchmarks](docs/efficiency.md) · [Known Issues](docs/known-issues.md)
124
+ - [Security, Privacy & Licensing](docs/security-and-copyright.md) · [Protected Files](docs/protected-files.md) · [Password Mode Design](docs/design-password-mode.md) · [Python Support](docs/python-support.md) · [Dependencies Audit](docs/dependencies.md) · [Claims Map](docs/claims.md) · [Credits](docs/credits.md)
125
+ - [Contributing](CONTRIBUTING.md) · [Code of Conduct](CODE_OF_CONDUCT.md) · [Security Policy](SECURITY.md) · [Changelog](CHANGELOG.md)
@@ -0,0 +1,85 @@
1
+ # THIRD_PARTY_NOTICES.md — Third-Party Dependency Notices
2
+
3
+ The core `tlate` package has **no mandatory third-party dependencies** (Python 3.12+ standard library
4
+ only). No third-party libraries are vendored in this repository.
5
+
6
+ The tables below document all optional dependencies (*extras*), development dependencies (`[dev]`),
7
+ optional external binaries/`tessdata`, and build/audit tooling declared in
8
+ [pyproject.toml](pyproject.toml) and audited in [docs/dependencies.md](docs/dependencies.md).
9
+
10
+ ## Optional Dependencies (Runtime Extras)
11
+
12
+ | Package | Extra | Purpose | License | Source |
13
+ |---|---|---|---|---|
14
+ | `lxml` | `[office]`, `[all]`, `[dev]` | Direct XML manipulation for DOCX, PPTX, XLSX (`resolve_entities=False`) | BSD-3-Clause | https://lxml.de/ |
15
+ | `PyYAML` | `[yaml]`, `[all]`, `[dev]` | YAML node parsing (`safe_load`) for in-place edits | MIT | https://pyyaml.org/ |
16
+ | `Pillow` | `[compare]`, `[ocr]`, `[all]`, `[dev]` | Side-by-side PNG comparison images, OCR image preprocessing, bbox overlays, and flagged crops | MIT-CMU (HPND) | https://python-pillow.org/ |
17
+ | `pypdfium2` | `[ocr]`, `[dev]` | Permissive PDF page rasterization, text-layer inspection, and pixel-diff evaluation (without PyMuPDF) | BSD-3-Clause / Apache-2.0 (PDFium: BSD-3-Clause / Apache-2.0) | https://github.com/pypdfium2-team/pypdfium2 |
18
+ | `tesserocr` | `[ocr]` | Local deterministic Tesseract C++ API wrapper (`PyTessBaseAPI`); prebuilt Win/Linux wheels bundle `libtesseract` (`Apache-2.0`) + `leptonica` (`BSD`-like); requires local `tessdata` (`*.traineddata`, `Apache-2.0`) | MIT | https://github.com/sirfz/tesserocr |
19
+ | `pymupdf` | `[pdf]`, `[all]` | Strictly optional PDF backend (extraction, redaction, Story rewriting, rendering; `pymupdf 2.x` on Python `3.12–3.14` also pulls `pymupdf-layout` & `pymupdf4llm` companions plus `networkx` `BSD-3-Clause`, `numpy` `BSD-3-Clause`, `onnxruntime` `MIT`, `pyyaml` `MIT`, `psutil` `BSD-3-Clause`, `tabulate` `MIT`; on Python `3.15`, `1.28.2` resolves with `0` transitive deps) | **GNU AGPL-3.0 or Artifex commercial license** | https://pymupdf.readthedocs.io/ |
20
+
21
+ ### PyMuPDF (`[pdf]`) Special License Notice
22
+ **PyMuPDF** (MuPDF) is dual-licensed under the **GNU Affero General Public License v3.0 (AGPL-3.0)**
23
+ or an **Artifex Software commercial license** (https://artifex.com/licensing). PyMuPDF is strictly
24
+ **optional**, **never vendored**, and only used when the user installs the `[pdf]` extra. Users who
25
+ install, distribute, or run `tlate[pdf]` (including as a network service) are solely responsible for
26
+ complying with the AGPL-3.0 terms or obtaining an Artifex commercial license. This notice is not
27
+ legal advice.
28
+
29
+ ## Optional External Binaries, OCR Models, & `tessdata`
30
+
31
+ | Asset / Binary | Scope | Purpose | License | Source |
32
+ |---|---|---|---|---|
33
+ | `tessdata` (`*.traineddata`) | Required at runtime for `tesserocr` (`[ocr]`) / `tesseract` | Language training data supplied locally via `TLATE_TESSDATA_DIR` / `TESSDATA_PREFIX` (or downloaded only with explicit user consent) | Apache-2.0 | https://github.com/tesseract-ocr/tessdata_fast |
34
+ | `Tesseract` CLI binary | Optional external (`--engine tesseract`) | Direct CLI fallback invoked via `subprocess` (`tsv`), no `pytesseract` required | Apache-2.0 | https://github.com/tesseract-ocr/tesseract |
35
+ | `RapidOCR` ONNX models | Optional user-installed fallback (`--engine rapidocr`, not declared in `pyproject.toml`) | PaddleOCR PP-OCR models bundled inside `rapidocr` if installed separately by the user | Apache-2.0 | https://github.com/RapidAI/RapidOCR |
36
+ | `Hunspell` CLI | Optional external (`tlate qa`) | System `hunspell` subprocess spellcheck when installed on `PATH`; never linked or vendored | MPL-1.1 / GPL-2.0 / LGPL-2.1 (CLI subprocess only) | https://hunspell.github.io/ |
37
+
38
+ ## PDF Library Evaluation Summary
39
+
40
+ | Library | License | Scope / Capability in `tlate` | Architectural Decision |
41
+ |---|---|---|---|
42
+ | `pymupdf` | **GNU AGPL-3.0 or Artifex commercial license** | Full block/style extraction, safe non-image/non-vector redaction (`fill=None`), MuPDF Story HTML/CSS layout fitting, bookmark updates, font subsetting | Kept strictly **optional** (`[pdf]` extra only, never vendored) behind `PdfEngine` |
43
+ | `pypdfium2` | BSD-3-Clause / Apache-2.0 | PDFium page rasterization and text-layer inspection | Powers `[ocr]` and `150` DPI pixel-diff evaluation in `tlate.pdf.metrics` without requiring PyMuPDF |
44
+ | `pikepdf` | MPL-2.0 | Low-level PDF object/content-stream manipulation (QPDF) | Not used as primary rewrite backend (no built-in HTML/CSS reflow, font subsetting, or Story layout engine) |
45
+ | `reportlab` | BSD | Programmatic PDF generation from scratch | Creation-only library; cannot inspect, redact, or adaptively rewrite existing PDF pages |
46
+ | `fonttools` | MIT | Font table parsing and subsetting | Font utility only; not a PDF parser, redactor, or layout renderer |
47
+ | `pypdf` | BSD-3-Clause | Pure-Python PDF merging, splitting, and object traversal | Object-level utility only; lacks layout extraction, redaction, and adaptive box reflow |
48
+
49
+ ## PDF Font Licenses
50
+
51
+ When `[pdf]` (`PyMuPDF` / MuPDF Story) rewrites translated text, embedded fonts come from MuPDF's
52
+ bundled font set or the optional `pymupdf-fonts` extra (see [src/tlate/pdf/fonts.py](src/tlate/pdf/fonts.py)):
53
+
54
+ | Font / Package | Source | License | Target Script Coverage |
55
+ |---|---|---|---|
56
+ | `Nimbus Sans` (`helv`), `Nimbus Roman` (`tiro`), `Nimbus Mono` (`cour`) | MuPDF bundled Base-14 | **URW / GNU AGPL-3.0** (bundled in MuPDF) | Latin scripts (`en`, `id`, European languages) |
57
+ | `Droid Sans Fallback` (`cjk` / `japan`) | MuPDF bundled CJK | **Apache-2.0** (bundled in MuPDF) | CJK (`ja`, `zh`, `ko`) |
58
+ | `Noto Naskh Arabic`, `Noto Serif Hebrew`, `Noto Serif Thai` | MuPDF Story bundled fonts | **SIL OFL-1.1** (bundled in MuPDF Story) | Arabic/Persian/Urdu (`ar`, `fa`, `ur`), Hebrew (`he`), Thai (`th`) |
59
+ | `Charis SIL` | MuPDF Story bundled font | **SIL OFL-1.1** (bundled in MuPDF Story) | Cyrillic & extended Latin (`ru`, `uk`, `bg`, `sr`, `be`) |
60
+ | `pymupdf-fonts` *(optional extra)* | External optional package | **SIL OFL-1.1** | Additional Noto/CJK/international glyphs if installed separately by the user |
61
+
62
+ ## Development, Build & Security Audit Dependencies (`[dev]` & CI)
63
+
64
+ OOXML test and evaluation fixtures are generated directly with Python stdlib `zipfile` +
65
+ `xml.etree.ElementTree` ([tests/ooxml_fixtures.py](tests/ooxml_fixtures.py)), with zero dependency
66
+ on `python-docx`, `python-pptx`, or `openpyxl`.
67
+
68
+ | Package | Purpose | License | Source |
69
+ |---|---|---|---|
70
+ | `pytest` | Running the test suite (pulls `iniconfig` MIT, `pluggy` MIT, `packaging` Apache-2.0/BSD-2-Clause, `Pygments` BSD-2-Clause, `colorama` BSD-3-Clause) | MIT | https://docs.pytest.org/ |
71
+ | `ruff` | Python linting and formatting checks | MIT | https://docs.astral.sh/ruff/ |
72
+ | `lxml` | Testing OOXML handlers (`[office]` / `[dev]`) | BSD-3-Clause | https://lxml.de/ |
73
+ | `PyYAML` | Testing YAML handler and CI YAML checks (`[yaml]` / `[dev]`) | MIT | https://pyyaml.org/ |
74
+ | `Pillow` | Testing compare/OCR image helpers (`[compare]` / `[dev]`) | MIT-CMU (HPND) | https://python-pillow.org/ |
75
+ | `pypdfium2` | Creating and testing PDF/OCR fixtures in tests | BSD-3-Clause / Apache-2.0 | https://github.com/pypdfium2-team/pypdfium2 |
76
+ | `setuptools` | PEP 517 build backend (`[build-system]`) | MIT | https://setuptools.pypa.io/ |
77
+ | `build` *(release build)* | Building sdist and wheel artifacts (pulls `pyproject_hooks` MIT) | MIT | https://build.pypa.io/ |
78
+ | `twine` *(release check)* | Validating distribution metadata (`twine check dist/*`; pulls `readme-renderer` Apache-2.0, `docutils` Public Domain / BSD-2-Clause / optional GPL scripts, `keyring` MIT, `nh3` MIT, `rfc3986` Apache-2.0, `requests-toolbelt` Apache-2.0, `id` Apache-2.0) | Apache-2.0 | https://twine.readthedocs.io/ |
79
+ | `pip-audit` *(CI/release audit)* | Auditing installed packages against PyPI/OSV advisories (pulls `CacheControl`, `cyclonedx-python-lib`, `pip-api`, `pip-requirements-parser`, `rich`, `tomli`, `tomli-w`, `platformdirs`, `requests`, etc.) | Apache-2.0 | https://github.com/pypa/pip-audit |
80
+
81
+ ## External Reference Note
82
+
83
+ - `Overdue-Lin/pdf-translate-skill` was reviewed solely as a workflow-idea reference (hybrid
84
+ planning); that repository lacked a `LICENSE` file, so **zero code and zero assets** were copied
85
+ from it.
@@ -0,0 +1,78 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tlate"
7
+ version = "0.1.0"
8
+ description = "Deterministic extract/apply/QA engine so AI agents translate documents across languages without overwriting sources."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE", "THIRD_PARTY_NOTICES.md"]
12
+ authors = [{ name = "Sendy" }]
13
+ requires-python = ">=3.12"
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Programming Language :: Python :: 3.15",
22
+ "Topic :: Text Processing :: Linguistic",
23
+ ]
24
+ dependencies = []
25
+
26
+ [project.optional-dependencies]
27
+ office = ["lxml>=6.0"]
28
+ yaml = ["PyYAML>=6.0.2"]
29
+ # PyMuPDF is dual-licensed AGPL-3.0 / Artifex commercial. Optional, never vendored.
30
+ pdf = ["pymupdf>=1.28.2"]
31
+ compare = ["Pillow>=12.0"]
32
+ ocr = ["pypdfium2>=5.0", "Pillow>=12.0", "tesserocr>=2.13.0"]
33
+ all = ["lxml>=6.0", "PyYAML>=6.0.2", "pymupdf>=1.28.2", "Pillow>=12.0"]
34
+ dev = [
35
+ "pytest>=9.0",
36
+ "ruff>=0.14",
37
+ "lxml>=6.0",
38
+ "PyYAML>=6.0.2",
39
+ "Pillow>=12.0",
40
+ "pypdfium2>=5.0",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/sndiy/tlate"
45
+ Repository = "https://github.com/sndiy/tlate"
46
+ Issues = "https://github.com/sndiy/tlate/issues"
47
+
48
+ [project.scripts]
49
+ tlate = "tlate.cli:main"
50
+
51
+ [tool.setuptools.packages.find]
52
+ where = ["src"]
53
+
54
+ [tool.setuptools.package-data]
55
+ tlate = [
56
+ "kit_data/*.md",
57
+ "kit_data/dot_cursor/rules/*.mdc",
58
+ "kit_data/dot_github/*.md",
59
+ "kit_data/skills/tlate/*.md",
60
+ "kit_data/skills/tlate/assets/*.md",
61
+ "kit_data/skills/tlate/references/*.md",
62
+ "kit_data/skills/tlate/references/style-guides/*.md",
63
+ "languages_data/*/*.json",
64
+ "languages_data/*/*.md",
65
+ ]
66
+
67
+ [tool.pytest.ini_options]
68
+ testpaths = ["tests"]
69
+ pythonpath = ["src"]
70
+ addopts = "-ra"
71
+
72
+ [tool.ruff]
73
+ line-length = 120
74
+ target-version = "py312"
75
+
76
+ [tool.ruff.lint]
77
+ select = ["E", "F", "W", "I", "B", "UP"]
78
+ ignore = ["B905"]
tlate-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ """tlate: deterministic document plumbing for multi-language AI translation.
2
+
3
+ The model only translates text segments; this package extracts segments, protects
4
+ placeholders, re-applies translations into the original format, and checks safety
5
+ invariants (never overwrite, SHA-256 verification, refuse encrypted inputs).
6
+ """
7
+
8
+ __version__ = "0.1.0"
@@ -0,0 +1,3 @@
1
+ from tlate.cli import main
2
+
3
+ raise SystemExit(main())