Skip to main content

Batch translate .po and .ts files using AI

Project description

po-translate

🌐 Batch translate .po and .ts localization files using AI or free services.

Features

  • 8 translation services – Free and paid options
  • Batch translation – Efficient API usage
  • Format support – gettext .po, Qt .ts, and OASIS .xliff/.xlf files
  • Glossary – Custom term lists via --glossary
  • Progress bar – Optional tqdm progress for large files
  • Preserves placeholders – Keeps {0}, %s, %d intact
  • Dry run mode – Preview changes before saving
  • LANG auto-detection – Defaults target language from system locale

Installation

Debian/Ubuntu

wget https://github.com/yeager/po-translate/releases/download/v1.5.0/po-translate_1.5.0_all.deb
sudo dpkg -i po-translate_1.5.0_all.deb

Fedora/RHEL/openSUSE

wget https://github.com/yeager/po-translate/releases/download/v1.5.0/po-translate-1.5.0-1.noarch.rpm
sudo rpm -i po-translate-1.5.0-1.noarch.rpm

Arch Linux

wget https://github.com/yeager/po-translate/releases/download/v1.5.0/po-translate-1.5.0.pkg.tar.zst
sudo pacman -U po-translate-1.5.0.pkg.tar.zst

Universal (tar.gz)

wget https://github.com/yeager/po-translate/releases/download/v1.5.0/po-translate-1.5.0.tar.gz
tar xzf po-translate-1.5.0.tar.gz -C /usr/local

Windows/macOS (zip)

Download po-translate-1.5.0.zip, extract, and add to PATH.

From source

git clone https://github.com/yeager/po-translate.git
cd po-translate
chmod +x po_translate.py
ln -s $(pwd)/po_translate.py /usr/local/bin/po-translate

Usage

Basic usage (free services)

# Translate with MyMemory (free, recommended)
po-translate --source en --target sv ./translations/

# Translate single file
po-translate --source en --target de messages.po

# Use LibreTranslate (self-hosted)
po-translate --service libretranslate --url http://localhost:5000 --source en --target fr ./po/

With paid services (better quality)

# DeepL (best for European languages)
po-translate --service deepl --api-key xxx --source en --target de ./po/

# DeepL Free API
po-translate --service deepl-free --api-key xxx --source en --target sv ./po/

# Google Cloud Translation
po-translate --service google --api-key xxx --source en --target ja ./po/

# OpenAI (context-aware, best quality)
po-translate --service openai --api-key sk-xxx --source en --target ja ./po/

# Anthropic Claude
po-translate --service anthropic --api-key sk-ant-xxx --source en --target ko ./po/

Options

Option Description
--source, -s Source language code (required)
--target, -t Target language code (required)
--service Translation service (default: lingva)
--api-key API key for paid services
--url Custom URL for LibreTranslate
--model Model for AI services
--batch-size Entries per API call (default: 10)
--glossary CSV glossary file for custom terms
--dry-run Preview without saving
--no-recursive Don't search subdirectories

Services

Free (no API key required)

Service Description Limits
lingva Google Translate frontend Rate limited
mymemory Translation memory 1000 words/day
libretranslate Self-hosted or public Depends on instance

Paid (API key required)

Service Description Pricing
deepl DeepL Pro API €5.49/month + usage
deepl-free DeepL Free API 500k chars/month
google Google Cloud Translation $20/million chars
openai GPT models (context-aware) ~$0.15/million tokens
anthropic Claude models ~$0.25/million tokens

Examples

Translate all untranslated strings

po-translate --source en --target sv ./resources/language/

Preview changes first

po-translate --dry-run --source en --target de ./translations/

Use DeepL for high-quality European translations

po-translate --service deepl --api-key $DEEPL_API_KEY \
  --source en --target de ./po/

Use GPT-4 for best quality (context-aware)

po-translate --service openai --api-key $OPENAI_API_KEY \
  --model gpt-4o --source en --target ja ./po/

Language codes

Use ISO 639-1 codes:

Code Language Code Language
en English ja Japanese
sv Swedish zh Chinese
de German ko Korean
fr French ar Arabic
es Spanish ru Russian
it Italian pt Portuguese
nl Dutch pl Polish

Tips

  1. Start with dry-run to preview translations
  2. Use DeepL for European languages (best quality)
  3. Use AI services for context-aware translations
  4. Increase batch-size for AI services (more efficient)
  5. Review translations – machine translation isn't perfect

Related tools

Requirements

  • Python 3.8+
  • No external dependencies (stdlib only)

License

GPL-3.0

Author

Daniel Nylander (@yeager)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

po_translate_ai-1.5.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

po_translate_ai-1.5.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file po_translate_ai-1.5.0.tar.gz.

File metadata

  • Download URL: po_translate_ai-1.5.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for po_translate_ai-1.5.0.tar.gz
Algorithm Hash digest
SHA256 4c9b57d25d10909d5c895445a4e85d449cdf22317b094746f622b4f1af8e2ea3
MD5 4207a48c9c9af372ef55fde0f02f9371
BLAKE2b-256 c404aa349321a120544e9884e771f2dea535b3024ed6ab38401f31890323ca53

See more details on using hashes here.

File details

Details for the file po_translate_ai-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for po_translate_ai-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 133268fa3e7e313f73d5304c30eabdb00c5d535000f3daddeb51eaf2b107ffec
MD5 5ea35c1a6cee2583165c642b3464d411
BLAKE2b-256 c8df513a74510e05939fa4b784f4a2c1d34a5ae449e8a39491ca5c53284595ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page