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

Add --no-untranslated to also fail when a message has an empty msgstr, which catches strings that were extracted but never translated:

django-makemessages-rs -l en -l zh_Hant --locale-dir locale \
  --check --no-untranslated

--dry-run computes everything and reports, but never touches the tree.

Compiling to .mo

--compile runs msgfmt --check-format over each .po it wrote, the same way Django's compilemessages does, so a single invocation can refresh and compile the catalogs:

django-makemessages-rs -l en -l zh_Hant --locale-dir locale --compile

Options

-l, --locale <LOCALES>       Locales to generate (repeatable)
-x, --exclude <LOCALES>      Locales to exclude (repeatable)
-a, --all                    Update all existing locales
-s, --symlinks               Follow symlinks to directories when scanning
-i, --ignore <PATTERNS>      Patterns to ignore (directories/files)
    --no-default-ignore      Don't ignore CVS, .*, *~, *.pyc
-d, --domain <DOMAIN>        Domain name: django or djangojs [default: django]
-e, --extension <EXTS>       File extensions to examine [default: html txt py, or js for djangojs]
-k, --keyword <SPEC>         Extra xgettext keywordspec, e.g. -k t or -k t:1c,2
                             (repeatable; -k '' drops the defaults)
    --add-comments [TAG]     Emit preceding comments as #. lines
                             [default tag: Translators; bare = all comments]
    --detect-aliases         Treat `import gettext as x` aliases as keywords
    --root <PATH>            Root directory to scan [default: .]
    --locale-dir <PATH>      Locale directory [default: locale]
    --locale-path <PATH>     Extra locale directories, like LOCALE_PATHS (repeatable)
    --per-app-locale         Write into each app's own locale/ dir, like Django
    --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)
    --dry-run                Compute everything but leave the tree untouched
    --no-untranslated        Exit with error if any message is untranslated
    --compile                Also compile .po to .mo afterwards (needs msgfmt)
    --width <WIDTH>          Wrap at this column instead of 80 (0 disables)
    --force-po               Write the .po even when it holds no messages
    --no-flag <FLAG>         Remove only this flag from '#,' lines (repeatable)
    --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
  • custom translation functions via --keyword, using xgettext's keywordspec syntax (name, name:2, name:1c,2, name:1,2)

Only arguments that are entirely string literals are extracted, matching xgettext: _(getattr(obj, 'verbose_name', label)) yields nothing, while _("a" "b") yields ab.

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

New .po files get the correct Plural-Forms for their locale, taken from a table generated out of Django's own shipped catalogs (98 locales; ja, ko and zh_* are nplurals=1, Russian and Polish get their 4-form rules, and so on). Unknown locales fall back to the base language, then to nplurals=2; plural=(n != 1);.

Per-app locale directories

By default everything is written to a single --locale-dir. Pass --per-app-locale to follow Django's layout instead: any directory named locale/ is treated as a locale root for the app containing it, and each file's messages go to the nearest enclosing one.

appA/locale/en/LC_MESSAGES/django.po   <- strings from appA/
appB/locale/en/LC_MESSAGES/django.po   <- strings from appB/
locale/en/LC_MESSAGES/django.po        <- everything else

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 django-extended-makemessages
cargo build --release
./tests/differential/run.sh

It needs GNU gettext (xgettext, msgmerge, msguniq, msgattrib) on PATH, plus django-extended-makemessages for the fixtures covering --keyword, --add-comments and --detect-aliases. Headers and #: locations are excluded from the comparison; everything else (msgid, msgid_plural, msgctxt, #. comments, ordering) must match exactly.

License

MIT

Metadata

Release files for django-makemessages-rs 0.8.0

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

Built distributions (wheels)

Table of built distributions (wheels) for django-makemessages-rs 0.8.0
File Actions
django_makemessages_rs-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for django_makemessages_rs-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
django_makemessages_rs-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for django_makemessages_rs-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
django_makemessages_rs-0.8.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for django_makemessages_rs-0.8.0-py3-none-macosx_11_0_arm64.whl
django_makemessages_rs-0.8.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for django_makemessages_rs-0.8.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 5.3 MB

Release files / django_makemessages_rs-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL django_makemessages_rs-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.4 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
5c958b54611f34eaf8db768d49488ca17842c930e5c145a905c70423ea70e077
BLAKE2b-256 checksum
How to use checksums
2f08523378e958d98dbe658083cd4a806efc03656a4f0d54bad27783dbcd5730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

Release files / django_makemessages_rs-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL django_makemessages_rs-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.3 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
3b2aa8d575aa0f1d2630c9588c01e42b36519a01bb92e769b951f8a126c79146
BLAKE2b-256 checksum
How to use checksums
972c05363fb2ad094dcd00e2319e8d1a40239e23b20875f77a04cacdbc459b6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

Release files / django_makemessages_rs-0.8.0-py3-none-macosx_11_0_arm64.whl

Download URL django_makemessages_rs-0.8.0-py3-none-macosx_11_0_arm64.whl
Size 1.2 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
032a1b57d0a05fe60b1a5cad7bdb16c6e345861f6f098d7c443cc123fdbdc352
BLAKE2b-256 checksum
How to use checksums
10a4ec5f31155a63b16b774abdb5b50f48c818de15ab6dcd034c7ca89981ba58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

Release files / django_makemessages_rs-0.8.0-py3-none-macosx_10_12_x86_64.whl

Download URL django_makemessages_rs-0.8.0-py3-none-macosx_10_12_x86_64.whl
Size 1.3 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ee15ef33c59daea7bad732d1bc9ccec97235feead2461678a6d7951b5c64dda5
BLAKE2b-256 checksum
How to use checksums
dab8185f3088fa75dff31369062ed2092728f67060bfc55591add2c9337744f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

Security for django-makemessages-rs 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for django_makemessages_rs-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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