DocuLingo
A command-line tool to translate large documents using language models. It preserves the file formatting and simplifies migrating documentation to other languages.
Table of Contents
- Overview
- Key Features
- Installation
- Quick Start
- CLI Reference
- Configuration
- Limitations
- Development
- License
Overview
doculingo helps you translate documents while preserving their formatting. It currently works with Word files and aims to support additional formats in the future, making it ideal for projects that require multiple language versions without losing the original layout.
Key Features
- ✨ Automatic Translation — uses OpenAI to safely translate paragraphs.
- 📝 Preserves Styles — copies fonts, colors, and alignment to the translated version.
- 📄 Document Support — currently handles large
.docxfiles with more formats planned. - 🔁 Automatic Retries — retries with exponential backoff when the API fails and exits with a clear error if all retries fail.
- ⚙️ Simple CLI — clear commands with built-in help.
Installation
Run instantly with uv without installing:
uvx doculingo --help
Or install from PyPI:
pip install doculingo
Quick Start
Translate a Word document from Spanish to English:
doculingo word \
--input file.docx \
--output translated.docx \
--language-source spanish \
--language-target english
CLI Reference
Get the full list of options with:
doculingo --help
The main subcommand is word, designed for .docx files:
| Option | Required | Default | Description |
|---|---|---|---|
--input, -i |
Yes | — | Input .docx file path. |
--output, -o |
Yes | — | Output file path. The .docx suffix is appended if missing. |
--language-source, -s |
Yes | — | Source language. For example: spanish. |
--language-target, -t |
Yes | — | Target language. For example: english. |
--translator |
No | openai |
Translator implementation. Only openai is available for now. |
--model |
No | gpt-4o |
Model used by the translator. |
--retries |
No | 5 |
Number of retries after the first failed translation attempt, with exponential backoff. |
Example using a different model and fewer retries:
doculingo word \
--input file.docx \
--output translated.docx \
--language-source spanish \
--language-target english \
--model gpt-4o-mini \
--retries 3
Configuration
doculingo reads configuration from environment variables (a local .env file is also supported). Copy .env.example to .env and fill in your values:
| Variable | Required | Description |
|---|---|---|
OPENAI_API_KEY |
Yes | OpenAI API key used by the OpenAI translator. Get one at platform.openai.com/api-keys. |
The model can be selected per run with --model; it defaults to gpt-4o.
Limitations
- Only top-level document paragraphs are translated. Content inside tables, headers and footers, and paragraphs inside shapes (text boxes, SmartArt) is not translated.
- Paragraphs made of multiple runs (mixed formatting within a paragraph) are translated as a whole, so their internal formatting is collapsed into a single run in the output document.
- The output document is rebuilt from paragraphs only, so other document parts such as images and tables are not carried over.
Development
Install the dependencies and run the tool locally:
uv lock
uv sync --all-groups --all-extras
uv run doculingo --help
Common tasks are available through the makefile:
make install # uv sync --all-groups --all-extras
make format # ruff format
make lint # ruff check
make type-check # mypy doculingo
make test # pytest
License
Distributed under the MIT license. See the license file.
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 doculingo-0.2.0.tar.gz.
File metadata
- Download URL: doculingo-0.2.0.tar.gz
- Upload date:
- Size: 62.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d40cb7087a7bfbf541a8b8c38aceec8010117e4afcca9693414028ff2589a854
|
|
| MD5 |
82771b466b092a33933f5dbe22e4079c
|
|
| BLAKE2b-256 |
ecedba427ee06d72f471555987c47b4018113408dafbc3d5948d5a48f8fd5028
|
Provenance
The following attestation bundles were made for doculingo-0.2.0.tar.gz:
Publisher:
release.yml on leynier/doculingo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doculingo-0.2.0.tar.gz -
Subject digest:
d40cb7087a7bfbf541a8b8c38aceec8010117e4afcca9693414028ff2589a854 - Sigstore transparency entry: 2471642183
- Sigstore integration time:
-
Permalink:
leynier/doculingo@aeb9eb2ed16773d660dafb0171f2cd30c077f074 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/leynier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aeb9eb2ed16773d660dafb0171f2cd30c077f074 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file doculingo-0.2.0-py3-none-any.whl.
File metadata
- Download URL: doculingo-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d26abe44d9c06fc16fb63cfcdecb7f9bc6df19569ea7e13c07635f57fef94e2b
|
|
| MD5 |
3b282663c0106ea08a17da0b717af77e
|
|
| BLAKE2b-256 |
eed4f2e85e60ecefb37aeb4275ca73607107a913dad94cdb6720cd8c2d1f2406
|
Provenance
The following attestation bundles were made for doculingo-0.2.0-py3-none-any.whl:
Publisher:
release.yml on leynier/doculingo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doculingo-0.2.0-py3-none-any.whl -
Subject digest:
d26abe44d9c06fc16fb63cfcdecb7f9bc6df19569ea7e13c07635f57fef94e2b - Sigstore transparency entry: 2471642219
- Sigstore integration time:
-
Permalink:
leynier/doculingo@aeb9eb2ed16773d660dafb0171f2cd30c077f074 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/leynier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aeb9eb2ed16773d660dafb0171f2cd30c077f074 -
Trigger Event:
workflow_dispatch
-
Statement type: