Translates a Word, PowerPoint or Excel file into another language with the layout and formatting kept, the assistant doing the translating.
Say it in your own words; the assistant finds this recipe by itself. Examples:
Translate a Word, PowerPoint or Excel file into another language while keeping its layout, formatting, tables, headers and slide design: two commands around the assistant's own translation. `extract` pulls every piece of text out of the file into a numbered JSON; you (the assistant) translate the JSON values; `apply` writes them back in place, formatting intact, and renders a PDF to check. Use for: translate this contract to English but keep the layout, Danish version of this deck, Excel sheet with the labels in German, oversæt dokumentet men behold opsætningen. Triggers: translate, translation, oversæt, oversættelse, in English, på dansk, auf Deutsch, keep the formatting, same layout.
python3 /skills/translate-document/scripts/translate.py <verb> …. Inputs in /work/in, results
in /work/out. Each verb prints one OK … line or one ERROR … line. The file never leaves
the sandbox; only the text segments pass through you.
| Step | Command |
|---|---|
| 1. Pull the text out | translate.py extract /work/in/contract.docx /work/segments.json → a JSON list of {"id": 1, "text": "…"} (one per run of text; the OK line gives the count and word total) |
| 2. Translate | read /work/segments.json, translate every text (keep numbers, names, placeholders and line breaks as they are; same tone and register), write /work/translated.json as a list of {"id": 1, "text": "…"} with the same ids |
| 3. Write it back | translate.py apply /work/in/contract.docx /work/out/contract-en.docx --translations /work/translated.json [--pdf /work/out/contract-en.pdf] |
Works for .docx (body, tables, headers, footers, footnotes), .pptx (slides, tables, notes) and
.xlsx (text cells and sheet names; numbers and formulas are left alone). Segments longer than
--max-chars 1500 are split at sentence ends so each piece fits comfortably. For a long document
translate in batches of ~60 segments and merge the lists before apply. If apply reports ids
missing, those segments keep the original text. Always render the --pdf and give the person
both links.
SKILL.mdgate.jsonscripts/__pycache__/translate.cpython-313.pycscripts/translate.pyWritten by Percerno, MIT licence.