Add i18n support for parser/lexer/schema error messages#1
Merged
Conversation
Wrap all user-facing error strings emitted by lexer.py, parser.py,
schema.py, views.py and exceptions.py with gettext_lazy so they can
be translated per the active Django locale. Multi-variable messages
use named .format() placeholders for translator-friendly reordering.
Translate the "DjangoQL syntax help" label in
templates/djangoql/error_message.html.
Ship translation catalogs for 11 locales: pl (hand-written, native),
plus de, fr, es, ru, uk, pt_BR, it, nl, ja, zh_Hans as auto-translated
seeds marked for native-speaker review.
Add an i18n test module that asserts error messages are translated
under override('pl') and stay English under override('en').
CI: install gettext and run `django-admin compilemessages` in the
djangoql/ directory before tests, so .po files are validated on
every matrix entry.
Update README with an Internationalization section and add an entry
to CHANGES.rst.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add trailing commas after the last (implicit-concat) string literal inside five multi-line `_(...)` gettext calls in schema.py. flake8-commas (which CI runs but my initial local check did not) requires a trailing comma whenever a function call's closing paren sits on its own line, regardless of arity. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a pre-commit configuration that runs flake8 (with the same flake8-builtins / flake8-commas / flake8-print / flake8-quotes plugins CI uses) and isort on staged files only. Catches the exact lint failures that CI catches, before the commit lands, without rechecking the rest of the repo on every commit. Versions are bumped past requirements-dev.txt to install on modern Python (3.10+); the rules enforced (C812, T2, A003, isort ordering) are the same as the CI pins. The `exclude` mirrors setup.cfg. Usage: pip install pre-commit && pre-commit install pre-commit run # staged files (auto-runs on git commit) pre-commit run --all-files # everything Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Django i18n support for every user-facing error message produced by DjangoQL — lexer, parser, schema validator, suggestions API view, and the small `error_message.html` template. Ships translation catalogs for 11 locales.
/LC_MESSAGES/`: `pl` is hand-written native-quality Polish (used as the canary by the i18n tests); `de`, `fr`, `es`, `ru`, `uk`, `pt_BR`, `it`, `nl`, `ja`, `zh_Hans` are auto-translated seeds with `# Auto-translated. Review by a native speaker welcome — open a PR.` markers in their `.po` headers.If a translation is missing for a string or locale, gettext falls back to the English source — so this is a strictly additive change.
Test plan
Notes for reviewers
🤖 Generated with Claude Code