Skip to main content

A fast Rust alternative to Django's makemessages command

Project description

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]
    --root <PATH>            Root directory to scan [default: .]
    --locale-dir <PATH>      Locale directory [default: locale]
    --no-location            Don't write #: filename:line lines
    --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 %}
  • {% blocktrans trimmed %} whitespace collapsing
  • {% blocktrans %}...{% plural %}...{% endblocktrans %} plural forms
  • Python implicit string concatenation (_("foo" "bar"))
  • Template variable substitution ({{ var }} to %(var)s)
  • Literal % escaping to %%

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

License

MIT

Project details


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.3.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.3.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.3.0-py3-none-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

django_makemessages_rs-0.3.0-py3-none-macosx_10_12_x86_64.whl (1.2 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for django_makemessages_rs-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9ad7c1d9edd8bbe8cd1d746606e6d820519468de2d484fc8d8a4c80cc3233ee
MD5 60cd47a565aaced992d2dc8f140e84cd
BLAKE2b-256 b33e63731f876ff11014d34911efc8c3f6f628facba728973e87847700218b84

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_makemessages_rs-0.3.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.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for django_makemessages_rs-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8aed0a5cade6b82e3f11ad1360f9a961d244ed5756508ddf120fa466a214cedd
MD5 9a25185393e759e0183087691b27dc3d
BLAKE2b-256 30842c190714f5fc0390e7cb19958ebb3a0775610f3da3383821e0e92b26c7e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_makemessages_rs-0.3.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.3.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for django_makemessages_rs-0.3.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a33a3fb305733af40c360c61cebb1dec75d5b00686ccd4892bfd593adccdf8de
MD5 0973aff67ca49ed53be3c0e792bb1241
BLAKE2b-256 6816190fda0afc0e62210ba680491171f48037d98fdcef95aa5f57b4684ff354

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_makemessages_rs-0.3.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.3.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for django_makemessages_rs-0.3.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8b6a3e00ae8ccc06c6438687db7db9a7ed6b3a1a8f252f7aa7d0ca0015fe7b4e
MD5 cf586b988de957ab02731315e37e1762
BLAKE2b-256 46b313daf9dacfbd9d46b09bdcb0388dfe6b9e83467c7421c22d2b1a6525ac92

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_makemessages_rs-0.3.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.

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