Translate .docx files while preserving all text formatting
Project description
Translate docx
A CLI tool and python library for translating .docx files, with a focus on preserving all text formatting.
Key Features
- Lossless round-trip - Extract and rebuild preserves all formatting
- Citation preservation - Superscripts (references) stay in original language
- Pluggable translators - Use any translation backend
- Section-based - Documents split by bold headers automatically
Installation
pip install translate-docx
Usage from Command Line
# Basic translation e.g. from spanish to english
translate-docx input.docx output.docx -s es -t en
# With options
translate-docx input.docx output.docx -s es -t en --delay 1.0 --verbose
# Show document info
translate-docx info document.docx
Usage as a Package
from translate_docx import (
extract_document,
translate_document,
rebuild_document,
GoogleTranslatorWrapper
)
doc = extract_document("input.docx")
translator = GoogleTranslatorWrapper(delay_between_calls=0.5, max_retries=3)
translated = translate_document(doc, translator, "es", "en")
rebuild_document(translated, "output.docx", template_path="input.docx")
Supported Language Codes
ar - Arabic
zh - Chinese (Simplified)
nl - Dutch
en - English
fr - French
de - German
it - Italian
ja - Japanese
ko - Korean
pl - Polish
pt - Portuguese
ru - Russian
es - Spanish
tr - Turkish
Known Limitations
- Tables and images not yet supported
- Headers/footers not yet supported
- Translated text may reflow (layout not guaranteed)
License
MIT
More Examples
See the examples/ directory for complete runnable scripts.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file translate_docx-2026.1.9rc1.tar.gz.
File metadata
- Download URL: translate_docx-2026.1.9rc1.tar.gz
- Upload date:
- Size: 87.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54dfe1f00b842961680f907a918e08d1e2ed5ada41e12a8709b35b6321a7f3fe
|
|
| MD5 |
8a2d76a917cb14a409abde6068890e8a
|
|
| BLAKE2b-256 |
6b8410640ff553e14b981d062d62202f2de7d240204b9aa44c654f561dd30dba
|
File details
Details for the file translate_docx-2026.1.9rc1-py3-none-any.whl.
File metadata
- Download URL: translate_docx-2026.1.9rc1-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
057c7526094c0f090aceb611053c758c9788ae339ec7ebb1c76eef0025474943
|
|
| MD5 |
254d29b2e919dc16768ab8c9700ab480
|
|
| BLAKE2b-256 |
7c921cf738189567fd77a1045e891c5ea1b1b0987b5c42c813c3482a2a9fde34
|