Django / Python
Django’s i18n is gettext at heart: django-admin makemessages produces the same .po and .pot catalogs
Dialecto edits. The dialecto-django package connects a Django project to Dialecto.
What works
The editing engine is runtime-agnostic gettext. Any valid PO file round-trips byte-faithfully, with its wrapping,
plural forms, obsolete #~ and previous #| entries, and all comment kinds, and every change lands as a
one-line-per-change diff. Django catalogs are valid PO catalogs, so the engine holds.
The package
dialecto-django has no runtime dependencies, and the scan never imports your project.
pip install dialecto-django
| Command | Does |
|---|---|
scan |
Sends the committed .po files to Dialecto, and with --usages every place the code and templates read a msgid. |
usages |
Prints what the usage scan found, in the view Dialecto gets. Sends nothing. |
check |
Re-scans and fails when code reads a msgid that no catalog holds. Sends nothing. |
doctor |
Checks Python, git, the catalogs, the token and the server. |
The scan needs the project’s scan token and number.
DIALECTO_SCAN_TOKEN=dlk_… DIALECTO_PROJECT=12 dialecto-django scan --usages
Catalog paths default to locale/**/*.po and */locale/**/*.po. Dialecto reads committed .po files only.
.mo files are build output: they are never read, sent or written, so run compilemessages in your own build
after a merged Dialecto pull request.
Live editing
Add the middleware under if DEBUG:, run runserver, and edit your own pages in Dialecto’s editor. It works in
development only. The Django live editing guide has the setup.