Skip to main content

Django translation management and auto-translation tools

Project description

django-po-tools

Command-line tools to manage Django translation files (.po/.mo) and auto-translate them using Google Translate.

Installation

pip install django-po-tools

Commands

Two commands are installed in the virtualenv:

  • djmessages — orchestrates makemessages, compilemessages, collect/install/remove workflows across multiple Django apps
  • po-auto-translate — auto-translates untranslated entries in a single .po file using Google Translate (with MyMemory as fallback)

djmessages

Run from the root of your Django project (where manage.py lives).

Configuration

On first run, djmessages creates a djmessages.conf file in the current directory and exits. Edit it before running again:

[general]
project=myproject
settings_module=myproject.settings
translations_target_folder=../translations
apps=app1, app2
Key Description
project Django project name
settings_module Dotted path to your Django settings module
translations_target_folder Folder used by collect / install commands
apps Comma-separated list of Django app names

Available languages are read automatically from LANGUAGES in your Django settings (excluding the default LANGUAGE_CODE).

Usage

djmessages <command> [-a <app> [app ...]] [-l <lang> [lang ...]]

If -a or -l are omitted, all configured apps or languages are used.

Commands

Command Description
make Run makemessages — extract translatable strings and create/update .po files
compile Run compilemessages — compile .po files into binary .mo files
collect Copy .po files into translations_target_folder for external translation
install Copy .po files back from translations_target_folder into each app's locale/
remove Delete the locale/<lang>/ folder for the given apps
autotranslate Auto-translate untranslated entries in .po files (calls po-auto-translate)

Options

-a, --apps       One or more app names, or "all"
-l, --languages  One or more language codes, or "all"
-f, --fuzzy      Mark new auto-translations as fuzzy
-d, --dry-run    Print commands without executing them
-v, --verbosity  Verbosity level (0-3, default 2)

Examples

# Extract strings for Italian and Spanish in two apps
djmessages make -a frontend main -l it es

# Compile all languages for all apps (options omitted = all)
djmessages compile

# Auto-translate missing strings in one app, mark as fuzzy for review
djmessages autotranslate -a frontend -l it es --fuzzy

# Dry-run: see what collect would do without touching files
djmessages collect --dry-run

po-auto-translate

Translates all untranslated entries in a single .po file. The target language is inferred from the file path (.../locale/<lang>/LC_MESSAGES/django.po).

po-auto-translate path/to/locale/it/LC_MESSAGES/django.po

Options

--source-language  Source language code (default: en)
-f, --fuzzy        Mark new translations as fuzzy
-d, --dry-run      Translate and print results without saving

Translation backends

  1. Google Translate (googletrans) — primary
  2. MyMemory (free REST API, no key required) — automatic fallback if Google fails

Format-string placeholders (%(name)s, {var}, etc.) are protected before translation and restored afterwards.


collect / install workflow

Useful when translations are done externally (e.g. by a translation agency):

myapp/locale/it/LC_MESSAGES/django.po
    → collect →
translations/it/it_myapp.po        ← send to translator
    → install →
myapp/locale/it/LC_MESSAGES/django.po

The collect command copies .po files into a flat, language-grouped folder. The install command is the reverse: it copies them back into the correct locale/ paths and removes stale .mo files.


License

GPL — Copyright (c) 2016-2026, Brainstorm S.r.l.

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

django_po_tools-1.5.3.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

django_po_tools-1.5.3-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file django_po_tools-1.5.3.tar.gz.

File metadata

  • Download URL: django_po_tools-1.5.3.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for django_po_tools-1.5.3.tar.gz
Algorithm Hash digest
SHA256 4d642608a881626b294a6dd340386b5e359636a22d55cadb3c51a874e5125a39
MD5 f36019c7b67e566573cb8968a2c4781f
BLAKE2b-256 d1e1b44334c76bcd01203c1baf15b9ea6626e0e794d3363fbcb766ac136f34b9

See more details on using hashes here.

File details

Details for the file django_po_tools-1.5.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_po_tools-1.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6240d9f35743482167a8b0a78ad8984e900879fe5419ef8f56ad43a671b6fbc5
MD5 e29812b12b38aa21a0e1cad13138193a
BLAKE2b-256 af36372c82ec79f491eecdfd1810cd03ffe1385d066930e5b6736f371dae7991

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