DOCX translator using DeepL
Project description
docx-translator-smith
A lightweight, developer-friendly DOCX translation tool powered by the DeepL API.
Provides both a Python library and CLI tools for batch-translating Microsoft Word (.docx) files while preserving structure.
✨ Features
- Translate DOCX documents using the DeepL API
- Preserve document structure (runs, paragraphs, tables)
- Automatic deduplication for translation memory efficiency
- Batch translation (entire folders)
- Benchmark mode to measure throughput and latency
- CLI commands suitable for automation
📦 Installation
pip install docx-translator-smith
Requires Python 3.11+.
🚀 Quick Start (CLI)
Translate an entire directory:
docx-translator translate-dir -s EN -t JA -i in_docs -o out_docs
Benchmark translation performance:
docx-translator-bench --src EN --tgt JA --input-dir in_docs --output-dir out_docs -v
🧰 Example Makefile for end users
If you prefer a simple make interface in your own project (not for developing this library itself), you can use a wrapper Makefile like the one below.
Adjust the VENV path to your virtual environment, save this as Makefile (or Makefile_sample.mk) in your project root, and run make help to see the available targets.
# Define variables
VENV := /path/to/venv
BIN = $(VENV)/bin
PYTHON = $(BIN)/python
.DEFAULT_GOAL := help
.PHONY: help ende deen ende-pro deen-pro
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@printf " \033[36m%-15s\033[0m %s\n" "help" "Show this help message"
@grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) \
| grep -v '^help:' \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
# ----------------------------------------------
# English <-> German Using FREE endpoint
# ----------------------------------------------
ende: ## Batch translate: in_docs -> out_docs, EN → DE
$(PYTHON) -m docx_translator.cli \
translate-dir \
-s EN -t DE \
-i in_docs -o out_docs \
deen: ## Batch translate: in_docs -> out_docs, DE → EN
$(PYTHON) -m docx_translator.cli \
translate-dir \
-s DE -t EN \
-i in_docs -o out_docs \
# ----------------------------------------------
# English <-> German Using PRO endpoint
# ----------------------------------------------
ende-pro: ## Batch translate: in_docs -> out_docs, EN → DE
$(PYTHON) -m docx_translator.cli \
translate-dir \
-s EN -t DE \
-i in_docs -o out_docs \
--pro
deen-pro: ## Batch translate: in_docs -> out_docs, DE → EN
$(PYTHON) -m docx_translator.cli \
translate-dir \
-s DE -t EN \
-i in_docs -o out_docs \
--pro
This sample Makefile is not installed by the package; it is only provided here as a reference for end users who like a make-based workflow.
🐍 Quick Start (Python)
from docx_translator.core.translator import translate_docx
src_path = "example.docx"
dst_path = "example.ja.docx"
translate_docx(src_path, dst_path, src_lang="EN", tgt_lang="JA")
🔑 Requirements
- DeepL API key
- Python 3.11 or later
python-docx,requests
Export your DeepL API key:
export DEEPL_API_KEY="your-key"
🛠 Development
git clone https://github.com/yeiichi/docx-translator
cd docx-translator
make venv
make install
make test
Build & publish:
make build
make dist-check
make publish
📄 License
MIT License © 2025 Eiichi Yamamoto
See LICENSE for full text.
👤 Author
Eiichi Yamamoto
📌 Project Status
This is an Alpha release — stable for CLI use, but internal APIs may evolve.
🔗 Links
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 docx_translator_smith-0.1.1.tar.gz.
File metadata
- Download URL: docx_translator_smith-0.1.1.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8434f251380a2c71d18b076ec9ac1bad106c6e66ad13f5fe91a4edf11b0319e1
|
|
| MD5 |
ba477b2142ff656d74aa03f94e1ea248
|
|
| BLAKE2b-256 |
4490b18a61f2edf4ae0e9bea8906608b7c1729fdbbb31837e0d3001c57063a4c
|
File details
Details for the file docx_translator_smith-0.1.1-py3-none-any.whl.
File metadata
- Download URL: docx_translator_smith-0.1.1-py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41e66bbbc8b7eeae5f376c27d6685a1bf7263ccec16feba3b4298c5ff38f74f1
|
|
| MD5 |
faa1ddefd4367ba62aafd72ddc0c685a
|
|
| BLAKE2b-256 |
443bafdc8f5e79cb309c9b4b19751c2531c43b27617d5db90a0b2e9561178256
|