DOCX Translator
Operator: Abdulla Al Fahad. How tools are built and checked
A Word file stores one sentence as several runs, one for each change of font, bold or colour, so pasting the text into a translator and pasting it back loses every style on the way. This page works on the runs themselves: it translates each paragraph as a whole and then writes the result back into the same runs, so headings, tables, headers and footers keep the formatting you set.
The translation model runs in the browser tab. Most language pairs use one OPUS-MT model of about 113 MB; the rest go through two of them via English or through M2M100.
Key features
- Body text, tables, headers, footers, footnotes and endnotes are read from a .docx of up to 25 MB, 8,000 pieces of text and 400,000 characters; comments are left alone
- 26 languages, with a glossary of terms to leave as typed and a review list where every different sentence can be edited before the file is built
- Run formatting kept: the translation is spread back over a paragraph's runs in proportion to their lengths, and a run that is a name or number is pinned to where it appears in the translation
- A translated .docx, or a side-by-side .docx with the original in a left column and the translation in a shaded right column
How translated text goes back into the runs
A paragraph is cut into pieces wherever the text is interrupted by a tab, a line break, a picture, a footnote mark, an equation or a field. Each piece is translated on its own, so 'Name:' and the name after the tab never become one sentence. Text shown by a field such as a page number or a date is not touched; the display text of a hyperlink field is translated. Text boxes are read, and so is the older copy of a text box that Word keeps for earlier versions.
Only the text nodes and the proofing language of their runs are rewritten. The language is set to the target (Spanish becomes es-ES, Portuguese pt-BR, Norwegian nb-NO) so Word does not underline the whole file as misspelled.
How it works
Identical pieces are sent once. Long paragraphs are cut into chunks of at most 300 characters at sentence ends so that the model does not stop early, and the chunks are joined again before the text is mapped back.
Glossary terms are swapped for neutral tokens before translation and restored afterwards. A piece that consists only of a glossary term is not sent at all. When a token is missing from the model's output, the page counts the lost terms and reports the number, so you know how many to restore in the review list.
The translated paragraph is split over its runs. A run holding only spaces keeps them. A run of three or more characters that occurs exactly once in the translation, as whole words, is pinned there. The stretches between pinned runs are shared out in proportion to the original run lengths, and every cut moves to the nearest word start, or to any character for Chinese, Japanese, Korean and Thai.
For the side-by-side file the translation is made first, then the body is rebuilt as a table with one row per paragraph. Pictures, bookmarks, footnote marks and comment anchors appear only in the left copy so that no identifier occurs twice; a section break moves to a small paragraph after the table.
Common use cases
- A 14-page supplier contract with 3 tables and a footer on every page goes from English to German with the single en-de model, 113 MB on the first run; the tables and footer come back in the same cells and styles.
- A translator receives a 6,000-word manual and ticks Side-by-side output, so the client can compare each paragraph with its Spanish version and mark corrections in the right column.
- A school office translates a 2-page letter to parents into Ukrainian and lists the school's name and the head teacher's name as terms to keep.
How to use this tool
- Drop a .docx onto the page, or press Load a sample .docx.
- Choose the source and target languages and list any terms to leave as they are.
- Press Translate; the first run downloads the model, and Cancel stops it.
- Read the review list, correct any sentence, and tick Side-by-side output if you want two columns.
- Press Download and open the file in Word or LibreOffice.
Example
Load a sample .docx (English), glossary 'Acme Corp', then a translation such as the one below
Sample: 9 paragraphs, 9 pieces of text, 264 characters in the body, header and footer; one field result (the page number) is left untouched. The sentence 'The supplier will deliver [bold: twelve monthly reports] to the client by the fifth working day of each month.' has three runs of 27, 22 and 53 characters.Spanish file
If the model returns 'El proveedor entregará doce informes mensuales al cliente a más tardar el quinto día hábil de cada mes.', the three runs get 'El proveedor entregará doce ', 'informes mensuales ' (bold) and 'al cliente a más tardar el quinto día hábil de cada mes.'. The bold lands on two of the three Spanish words for 'twelve monthly reports'; with 'Use the first run's formatting' ticked the whole sentence would be plain instead. 'Acme Corp' is restored in 'Las preguntas sobre este resumen se dirigen al soporte de Acme Corp.'Common pitfalls
Machine translation is a draft. The model sees one paragraph at a time, so a pronoun that refers to the previous paragraph is guessed.
In the side-by-side file the left column is half the text width, so wide pictures overflow it. Tables are kept at full width instead and followed by their translated copy.
Paragraph direction is not changed, only the text and its proofing language. After translating into Arabic or Hebrew, select the document in Word and set the paragraph direction to right-to-left in the paragraph settings; until then the text keeps the left-to-right alignment of the original.
A translation longer than the original, as English to German or Finnish usually is, can push a fixed-height table row or text box past its frame.
- Check the bold or italic phrases in the review list first: those are the runs where the proportional spread can put the formatting one word off. Names and numbers are pinned and do not drift.
- List product names, defined terms and article numbers in the glossary. Short capitalised words, such as a company name that is also an ordinary word, are the ones most likely to be translated by mistake.
Common errors and how to fix them
- "letter.docx" is an old .doc file or a password-protected document
- Open it in Word, remove the password or choose Save As .docx, and use that copy.
- unpacks to more than 400 MB, far beyond a normal file, so it was refused as a possible decompression bomb
- The parts of the package, pictures and embedded files included, inflate to more than 400 MB in total. Re-save the document from Word, or remove the oversized embedded object, and open that copy.
- declares its own XML entities (a DOCTYPE block)
- Word never writes a DOCTYPE into a document part, and this page does not expand custom entities, so such a file is refused rather than translated wrongly. Re-save it from Word or LibreOffice.
- "manual.docx" has 9,420 text pieces; the limit is 8,000
- Split the file at a chapter break, translate each part and join them in Word.
- The model for this language pair did not finish downloading
- Check that huggingface.co is reachable and that no content blocker is stopping it; pieces already downloaded are kept, so a second try resumes.
Best practices
- Save the review list edits by downloading; closing the tab discards them, because the model output is not stored.
Models and licences
OPUS-MT pairs come from the Helsinki-NLP project under CC BY 4.0, in ONNX form for the browser. For a pair with no direct model, such as Czech to German, the page translates into English and then out of it when both OPUS-MT halves exist; every other pair uses M2M100-418M from Meta (MIT licence, about 640 MB). The route and download size are shown above the Translate button before anything is fetched. The same engine translates subtitles on the Subtitle Translator page.
Frequently asked questions
Why is my table translated but my table of contents not?
A table of contents is a field, and the text a field displays is regenerated by Word. Update the field after translating (select it and press F9) so it picks up the translated headings.
Does the language of the document change for spell-checking?
Yes. Every run that received translated text is tagged with the target language, so Word checks Spanish text as Spanish. Runs left untouched keep their original tag.
Can I translate the comments?
No. Comment balloons are skipped and the page tells you how many comment parts the file has, because translating a reviewer's remark would change what it says about the original text.