Skip to content

πŸ” AI-powered translator for gettext .po files using OpenAI, Azure OpenAI, Claude, and DeepSeek – supports bulk, fuzzy cleanup, and language auto-detection.

License

Notifications You must be signed in to change notification settings

pescheckit/python-gpt-po

Repository files navigation

GPT-PO Translator

Python Package CI PyPI Downloads

Translate gettext (.po) files using AI models. Supports OpenAI, Azure OpenAI, Anthropic/Claude, and DeepSeek with automatic AI translation tagging.

πŸš€ Quick Start

# Install
pip install gpt-po-translator

# Set API key
export OPENAI_API_KEY='your_api_key_here'

# Translate to German and French
gpt-po-translator --folder ./locales --lang de,fr --bulk

✨ Key Features

  • Multiple AI providers - OpenAI, Azure OpenAI, Anthropic/Claude, DeepSeek
  • AI translation tracking - Auto-tags AI-generated translations with #. AI-generated comments
  • Bulk processing - Efficient batch translation for large files
  • Smart language detection - Auto-detects target languages from folder structure
  • Fuzzy entry handling - Translates and fixes fuzzy entries properly
  • Docker ready - Available as container for easy deployment

πŸ“¦ Installation

PyPI (Recommended)

pip install gpt-po-translator

Docker

docker pull ghcr.io/pescheckit/python-gpt-po:latest

Manual

git clone https://github.com/pescheckit/python-gpt-po.git
cd python-gpt-po
pip install -e .

πŸ”§ Setup

API Keys

Choose your AI provider and set the corresponding API key:

# OpenAI
export OPENAI_API_KEY='your_key'

# Anthropic/Claude
export ANTHROPIC_API_KEY='your_key'

# DeepSeek
export DEEPSEEK_API_KEY='your_key'

# Azure OpenAI
export AZURE_OPENAI_API_KEY='your_key'
export AZURE_OPENAI_ENDPOINT='https://your-resource.openai.azure.com/'
export AZURE_OPENAI_API_VERSION='2024-02-01'

πŸ’‘ Usage Examples

Basic Translation

# Translate to German
gpt-po-translator --folder ./locales --lang de

# Multiple languages
gpt-po-translator --folder ./locales --lang de,fr,es --bulk

Different AI Providers

# Use Claude (Anthropic)
gpt-po-translator --provider anthropic --folder ./locales --lang de

# Use DeepSeek
gpt-po-translator --provider deepseek --folder ./locales --lang de

# Use Azure OpenAI
gpt-po-translator --provider azure_openai --folder ./locales --lang de

Docker Usage

# Basic usage
docker run -v $(pwd):/data \
  -e OPENAI_API_KEY="your_key" \
  ghcr.io/pescheckit/python-gpt-po:latest \
  --folder /data --lang de,fr --bulk

# With Azure OpenAI
docker run -v $(pwd):/data \
  -e AZURE_OPENAI_API_KEY="your_key" \
  -e AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/" \
  -e AZURE_OPENAI_API_VERSION="2024-02-01" \
  ghcr.io/pescheckit/python-gpt-po:latest \
  --provider azure_openai --folder /data --lang de

🏷️ AI Translation Tracking

All AI translations are automatically tagged for transparency and compliance:

#. AI-generated
msgid "Hello"
msgstr "Hallo"

This helps you:

  • Track which translations are AI vs human-generated
  • Comply with AI content disclosure requirements
  • Manage incremental translation workflows

Note: Django's makemessages removes these comments but preserves translations. Re-run the translator after makemessages to restore tags.

πŸ“š Command Reference

Option Description
--folder Path to .po files
--lang Target languages (e.g., de,fr,es)
--provider AI provider: openai, azure_openai, anthropic, deepseek
--bulk Enable batch translation (recommended)
--bulksize Entries per batch (default: 50)
--model Specific model to use
--list-models Show available models
--fix-fuzzy Translate fuzzy entries
--folder-language Auto-detect languages from folders
--no-ai-comment Disable AI tagging

πŸ› οΈ Development

Build Docker Locally

git clone https://github.com/pescheckit/python-gpt-po.git
cd python-gpt-po
docker build -t python-gpt-po .

Run Tests

# Local
python -m pytest

# Docker
docker run --rm -v $(pwd):/app -w /app --entrypoint python python-gpt-po -m pytest -v

πŸ“‹ Requirements

  • Python 3.9+
  • Dependencies: polib, openai, anthropic, requests, tenacity

πŸ“– Documentation

πŸ“„ License

MIT License - See LICENSE for details.

About

πŸ” AI-powered translator for gettext .po files using OpenAI, Azure OpenAI, Claude, and DeepSeek – supports bulk, fuzzy cleanup, and language auto-detection.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 3

  •  
  •  
  •