Translate Django .po files with AI

Translate Django .po files from the command line: TranslateBot is a free, open-source package that fills the empty msgstr entries with GPT, Claude, Gemini or DeepL. Run it after makemessages and only the new strings get translated.

uv add --dev translatebot-django
$ python manage.py translate --target-lang de
ℹ️  Found 3 untranslated entries
🔄 Translating with gpt-6-luna...

Processing: locale/de/LC_MESSAGES/django.po
✓ Translated 'Welcome back, %(username)s'
✓ Translated 'Your order ships on {date}'
✓ Translated 'Delete'
✨ Successfully updated locale/de/LC_MESSAGES/django.po

From makemessages to a translated app in three commands

Add the app and an API key from your provider to your settings:

# settings.py
import os

INSTALLED_APPS = [
    # ...
    "translatebot_django",
]
TRANSLATEBOT_API_KEY = os.getenv("TRANSLATEBOT_API_KEY")

Then run the usual Django workflow with one extra step in the middle:

python manage.py makemessages -a
python manage.py translate        # every language in LANGUAGES
python manage.py compilemessages

Without --target-lang, one run covers every language in your LANGUAGES setting. Use --dry-run first to list the strings it would translate without calling the API.

What happens to your .po files

  • Only empty and fuzzy entries are translated. Existing translations stay as they are unless you pass --overwrite, so you pay for 10 strings when you add 10.
  • Placeholders survive. %(name)s, {0}, %s and HTML tags are checked against the rules compilemessages uses. A translation that breaks one is retried once, then saved as a #, fuzzy draft so it can't break your build.
  • Plural forms and context work. With LLM providers, each plural form of the target language gets its own translation, and msgctxt keeps "May" the month apart from "May" the verb.
  • Your terminology stays the same. A TRANSLATING.md file in your repo holds your glossary and tone, and every run reads it.

Which AI model translates the strings

Any model LiteLLM supports works: OpenAI, Anthropic, Google Gemini, Azure and more, or DeepL through its own provider. The default is gpt-6-luna at $0.10 per million input tokens and $0.50 per million output tokens. You pay your provider directly; TranslateBot itself costs nothing.

Not sure which to pick? See the model comparison for Django translation and the cost table.

Fail the build when a string is missing

check_translations exits with code 1 when any .po file has an untranslated or fuzzy entry. With --makemessages it extracts strings first, so a new string without a translation can't reach production unnoticed.

python manage.py check_translations --makemessages

GitHub Actions and GitLab CI examples

Questions developers ask first

Is it really free?
Yes. The package is open source under the MPL 2.0 license. The only cost is the API usage you pay your AI provider.
Can I translate one app instead of the whole project?
Yes, pass --app blog. Repeat the flag for more apps.
Does it translate database content too?
With django-modeltranslation installed, translate --models fills the empty language columns of your registered models.
Which Django and Python versions are supported?
Django 4.2 to 6.1 on Python 3.11 or newer.
How does it compare to Rosetta, Weblate or Crowdin?
Those tools are built around people editing translations. TranslateBot is a command for developers who want the AI to do the first pass. See the comparisons.

Translate your next batch of strings

uv add --dev translatebot-django