Skip to main content

django-makemessages-rs

PyPI License: MIT

A fast Rust alternative to Django's makemessages command. Produces byte-identical .po file output compared to django-extended-makemessages.

Tested against a ~2000 file Django project with ~3000 translatable strings across 5 locales:

Tool Time
django-extended-makemessages ~21s
django-makemessages-rs ~0.3s

Install

pip install django-makemessages-rs

Platform wheels are available for macOS (arm64, x86_64) and Linux (x86_64, aarch64).

Usage

django-makemessages-rs \
  -l en -l zh_Hant -l zh_Hans -l ko -l ja \
  --ignore .venv --ignore node_modules \
  --no-location --no-flags --sort-output \
  --no-fuzzy-matching --keep-header \
  --locale-dir locale

CI check mode

Use --check to verify translation files are in sync with source code. Exits with code 1 if any .po file would change:

django-makemessages-rs \
  -l en -l zh_Hant \
  --ignore .venv --ignore node_modules \
  --no-location --no-flags --sort-output \
  --no-fuzzy-matching --keep-header \
  --locale-dir locale \
  --check

Options

-l, --locale <LOCALES>       Locales to generate (required, repeatable)
-i, --ignore <PATTERNS>      Patterns to ignore (directories/files)
-d, --domain <DOMAIN>        Domain name [default: django]
-e, --extension <EXTS>       File extensions to examine [default: html txt py, or js for djangojs]
    --root <PATH>            Root directory to scan [default: .]
    --locale-dir <PATH>      Locale directory [default: locale]
    --no-location            Don't write #: filename:line lines (shorthand for --add-location never)
    --add-location <MODE>    Controls #: location comments: full (default), file, or never
    --no-flags               Don't write #, flags lines
    --sort-output            Generate sorted output
    --no-fuzzy-matching      Do not use fuzzy matching
    --keep-header            Keep the existing .po file header
    --no-obsolete            Remove obsolete message strings
    --no-wrap                Don't break long message lines
    --check                  Exit with error if .po files would change (dry-run)
    --timing                 Show timing information

How it works

  1. Walks the project tree using ignore (same engine as ripgrep)
  2. Extracts translatable strings from .py and .html/.txt templates in parallel using rayon
  3. Merges extracted strings with existing .po files, preserving translations
  4. Writes updated .po files

The extractor handles:

  • Python gettext(), ngettext(), pgettext(), npgettext() and the _() alias
  • Django template tags: {% trans %}, {% translate %}, {% blocktrans %}, {% blocktranslate %}
  • context "..." on both {% translate %} and {% blocktranslate %}, emitted as msgctxt
  • {% blocktrans trimmed %} whitespace collapsing
  • {% blocktrans %}...{% plural %}...{% endblocktrans %} plural forms
  • _("...") constants in block tags, variable expressions and filter arguments ({{ foo|default:_("bar") }})
  • Translators: comments, from # in Python and {# ... #} / {% comment %} in templates, written out as #. lines
  • Python implicit string concatenation (_("foo" "bar")) and triple-quoted strings
  • Template variable substitution, including filters and dotted lookups ({{ user.name|upper }} to %(user.name|upper)s)
  • Literal % escaping to %%
  • JavaScript sources under --domain djangojs

Entries that disappear from the source are kept as #~ obsolete blocks so existing translations survive, matching gettext. Pass --no-obsolete to drop them instead.

No Django settings or DJANGO_SETTINGS_MODULE required — runs as a standalone CLI.

Pre-commit / Git hooks integration

Add to your pyproject.toml dev dependencies:

"django-makemessages-rs"

Then in your pre-commit script:

uv run django-makemessages-rs \
  -l en -l zh_Hant \
  --ignore .venv --ignore node_modules \
  --no-location --no-flags --sort-output \
  --no-fuzzy-matching --keep-header \
  --locale-dir locale

Testing

cargo test --release

There is also a differential suite that runs the real Django makemessages over the same fixtures and compares the extracted messages, so behavioral drift from Django gets caught:

python3 -m venv tests/differential/.venv
tests/differential/.venv/bin/pip install django
cargo build --release
./tests/differential/run.sh

It needs GNU gettext (xgettext, msgmerge, msguniq, msgattrib) on PATH. Headers and #: locations are excluded from the comparison; everything else (msgid, msgid_plural, msgctxt, #. comments, ordering) must match exactly.

License

MIT

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

django_makemessages_rs-0.5.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

django_makemessages_rs-0.5.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

django_makemessages_rs-0.5.0-py3-none-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

django_makemessages_rs-0.5.0-py3-none-macosx_10_12_x86_64.whl (1.3 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file django_makemessages_rs-0.5.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for django_makemessages_rs-0.5.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3583eb7184dd473c2fd5c63c7eb85dba0964d213cc3b7473cf6263eabbf39e7
MD5 2b4f357623bbdd2caceeef69469bbb69
BLAKE2b-256 de7a1099f4813a16e4108c5f5612718ceca2628b79fb4059cc196048ada3ca5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_makemessages_rs-0.5.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on zxzinn/django-makemessages-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_makemessages_rs-0.5.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for django_makemessages_rs-0.5.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 72f82d4e4bc588f56f7e53e46edc9b7ee620c404b6e519bb61554b4d023eb4c9
MD5 0686363fc7ca0422d626b0dcc7c2d3b3
BLAKE2b-256 2522cb8c94cd5ea15076b6512515c6b23d823c005c3609f1ff3c3192e85ae0bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_makemessages_rs-0.5.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on zxzinn/django-makemessages-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_makemessages_rs-0.5.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for django_makemessages_rs-0.5.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0f916e3067d88927959f5fd2e5dc266f7c4dfe4b9a502237648efeea8a88f5e
MD5 d4f4fd021a27950846b4aabc53f67aa3
BLAKE2b-256 a26cefac5d012055ac27c5f1cf149172cb6e757b261fc6a19ae3890be6ef1431

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_makemessages_rs-0.5.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on zxzinn/django-makemessages-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_makemessages_rs-0.5.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for django_makemessages_rs-0.5.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 56efa44e09b86360d749cf934291c25e66910927b7ba310df6e42240f32fb241
MD5 3d2e356a57fa47089a32694da0c777f3
BLAKE2b-256 e98c63327f517f2acca44db7c3982bbf4898ef708536ea74d8a6c8a68e077885

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_makemessages_rs-0.5.0-py3-none-macosx_10_12_x86_64.whl:

Publisher: release.yml on zxzinn/django-makemessages-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.8.0

4 files

0.7.0

4 files

0.6.0

4 files

This release

0.5.0 This release

4 files

0.4.0

4 files

0.3.2

4 files

0.3.1

4 files

0.3.0

4 files

0.2.0

4 files

0.1.4

4 files

0.1.2

4 files

0.1.1

3 files

0.1.0

3 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