Skip to main content

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.

Metadata

Release files for django-po-tools 1.5.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-po-tools 1.5.7
File Size Uploaded
django_po_tools-1.5.7.tar.gz 16.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-po-tools 1.5.7
File Interpreter ABI Platform
django_po_tools-1.5.7-py3-none-any.whl Python 3 none any Details

Total release size: 33.6 kB

Release files / django_po_tools-1.5.7.tar.gz

Download URL django_po_tools-1.5.7.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3e20175613c2280bf1b41b437e32f8864195090651da8b0e16efca522d831b82
BLAKE2b-256 checksum
How to use checksums
11c4fd42fa2913f0d27eb905ff66b2984603a266494b66e4a8772a4b790060b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / django_po_tools-1.5.7-py3-none-any.whl

Download URL django_po_tools-1.5.7-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22edd364108f65f83a265168e4ddc9e67e80c4d0db7d58130be476ade16771ea
BLAKE2b-256 checksum
How to use checksums
8b0e013ccfaa6ba6b52d396337fdd85cef1fb1239fc9c45077fd81521f4100fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

1.5.7 This release

2 release files

1.5.6

2 release files

1.5.5

2 release files

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page