-
Notifications
You must be signed in to change notification settings - Fork 2
Translate Markdown with DeepL
This script translates Markdown (.md) files using the DeepL Free API, overwrites the original files, and maintains
a .skiplist to prevent duplicate work.
-
✅ Translate single Markdown files or entire directories
-
✅ Overwrites original
.mdfiles -
✅ Automatically skips and logs empty files
-
✅
.skiplisttracks already translated files -
✅ Supports dry-run mode (no writing)
-
✅ Logs skipped files with reason to
logs/skipped.log -
✅ Reads DeepL API key from
.envfile
- Install dependencies (via Poetry):
poetry install- Set your DeepL API key in
.env:
DEEPL_AUTH_KEY=your_deepl_api_key_here
- Make sure this line is in
.gitignore:
.skiplist
logs/
.envpoetry run translate-book-deepl \
--file manuscript/chapters/01-intro.md \
--target-lang DEpoetry run translate-book-deepl \
--base-dir manuscript/chapters \
--target-lang DEpoetry run translate-book-deepl \
--file manuscript/chapters/01-intro.md \
--target-lang DE \
--dry-runBy default, the script assumes the source language is English.
To translate from German to English, add the --source-lang DE flag:
poetry run translate-book-deepl \
--source-lang DE \
--target-lang EN \
--base-dir manuscriptpoetry run translate-book-deepl \
--source-lang DE \
--target-lang EN \
--file manuscript/chapters/01-intro.md| Argument | Description | Example |
|---|---|---|
--file |
Translate a specific Markdown file | --file path/to/file.md |
--base-dir |
Translate all .md files recursively in folder |
--base-dir manuscript/ |
--target-lang |
Language code to translate into (required) | --target-lang DE |
--source-lang |
Language code to translate from (default: EN) | --source-lang DE |
--dry-run |
Skip writing and .skiplist update |
--dry-run |
-
Tracks files already processed
-
Used to skip files in future runs
- Contains lines like:
skiplist: manuscript/chapters/01-intro.md
empty: manuscript/chapters/05-empty.md
not_found: manuscript/chapters/ghost.md
-
🛡 Protect your
.env— never commit it to Git -
✍ Commit translations after verification
-
🧪 Use
--dry-runbefore bulk operations
DEEPL_AUTH_KEY=abc123-your-api-keyMIT or same license as your project.
This script uses the DeepL Free API with a free limit of 500,000 characters/month.
If DeepL isn’t enough or you want fallback options, here are more tools:
-
🔓 Open-source, REST API
-
Public instance:
https://libretranslate.com
curl -X POST https://libretranslate.com/translate \
-H 'Content-Type: application/json' \
-d '{
"q": "Hello!",
"source": "en",
"target": "fr",
"format": "text"
}'-
🔒 100% offline/local translation
-
Use in Python, no API key required
pip install argostranslate-
🧪 Best for custom/local AI setups
-
Requires Python and GPU for best performance
-
Self-hosted or offline use
If you want to avoid the complexity and costs of Google Translate, the DeepL Free API is a fantastic choice—with generous limits, great quality, and ease of use. Combine it with LibreTranslate for fallback or Argos Translate for local, offline use.
✨ Ready to build? Start with DeepL, and scale up with open-source alternatives when needed.
- Home
- Project Initialization
- Generate Project Structure
- How to Write a Book
- Developer Workflow & Makefile
- Chapter File Generator
- Generate Images
- Convert Markdown Images
- Bulk Change File Extensions
- Restructure Chapters
- Remove Bold from Markdown Headers
- Converting Markdown Bullets to Typographic Bullets
- Translate Markdown with DeepL
- Translate with LM Studio
- Translation CLI Commands
- Shortcuts for Translation
- Automatic Book Export
- Shortcuts for Export
- Export HTML Chapters (Comics)
- Export to EPUB 2
- Pandoc Batch Processor
- Export HTML Books to PDF (KDP Ready)
**Libraries: ** manuscripta | manuscript-tools