Skip to main content

DocuLingo

License: MIT Version Python versions CI Last commit Commit activity Stars Forks Watchers Contributors

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

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 .docx files 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.

Metadata

Release files for doculingo 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for doculingo 0.2.0
File Size Uploaded
doculingo-0.2.0.tar.gz 62.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for doculingo 0.2.0
File Interpreter ABI Platform
doculingo-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 72.9 kB

Release files / doculingo-0.2.0.tar.gz

Download URL doculingo-0.2.0.tar.gz
Size 62.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d40cb7087a7bfbf541a8b8c38aceec8010117e4afcca9693414028ff2589a854
BLAKE2b-256 checksum
How to use checksums
ecedba427ee06d72f471555987c47b4018113408dafbc3d5948d5a48f8fd5028
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / doculingo-0.2.0-py3-none-any.whl

Download URL doculingo-0.2.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d26abe44d9c06fc16fb63cfcdecb7f9bc6df19569ea7e13c07635f57fef94e2b
BLAKE2b-256 checksum
How to use checksums
eed4f2e85e60ecefb37aeb4275ca73607107a913dad94cdb6720cd8c2d1f2406
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page