feat(i18n): consume central translations from escalated-locale#49
Merged
Conversation
Add the central `escalated-locale` PyPI package as a dependency and
expose `escalated.locale_paths.get_locale_paths()` so host projects
(and our test settings) can layer the plugin-local override on top of
the central catalogue with the override winning.
Assumes the central package ships gettext artifacts at
`escalated_locale/locale/<lang>/LC_MESSAGES/django.{po,mo}`.
Document `get_locale_paths()` for host projects in README and add an Unreleased CHANGELOG entry covering the central locale consumption.
Verify the plugin-local override is always present, caller extras take priority, and `get_central_locale_path()` degrades gracefully when the `escalated-locale` package is not installed.
pip resolves escalated-locale from github.com/escalated-dev/escalated-locale via PEP 440 direct git URL (v0.1.1 tag, subdirectory=packages/pypi). Once published to PyPI this constraint can revert to "escalated-locale ~= 0.1". Also patch the missing-package test in tests/unit/test_locale_paths.py to intercept import_module on the loader module instead of builtins.__import__, since the central package is now installed via this dependency and the prior monkeypatch never reached the import call site.
…/UP045 Drop `typing.List`/`typing.Optional` in favor of PEP 585 / PEP 604 syntax (`list[str]`, `str | None`). Ruff's `UP` rules flag the legacy spellings and were failing CI for this branch. No behavior change.
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
Wire
escalated-djangoto consume translations from the new centralescalated-localePyPI package while keeping the plugin-local
escalated/locale/directory as a higher-priority override layer.
escalated-locale ~= 0.1topyproject.tomlruntime deps.escalated.locale_paths.get_locale_paths()composes aLOCALE_PATHS-compatible list with caller-supplied extras first,the plugin-local override next, and the central package last.
tests/settings.pyso CI exercises theoverride + central layering.
central package is not yet installed.
Assumption flagged for
escalated-localeThe central package must ship pre-compiled gettext artifacts at:
These are required for Django's gettext-based translation system to
pick the catalogues up via
LOCALE_PATHS. The canonical JSON shippedby the central repo is not directly consumable by Django, so the
package's build step needs to also emit
.po/.mofiles (e.g. viamsgfmtduring the wheel build). Ifescalated-localechooses adifferent layout, this PR's
escalated/locale_paths.py::get_central_locale_pathwill need a small tweak to point at the actual subdirectory.
Blocked on
escalated-localev0.1.0 PyPI publishExpected CI failure:
pip install -e ".[dev]"will fail in CIwith a
Could not find a version that satisfies the requirement escalated-locale ~= 0.1error until the central package ispublished to PyPI. Marking this PR as draft until that lands.
Once
escalated-locale 0.1.0is published with the .po/.mo layoutabove, CI should go green without further changes here.
Test plan
pytest tests/unit/test_locale_paths.pypasses locally (4/4).escalated-locale 0.1.0publishes — expectgreen.
LANGUAGE_CODE = "fr", and confirm a translated string from thecentral package renders. Then drop a same-key override into
escalated/locale/fr/LC_MESSAGES/django.poand confirm it wins.Files changed
pyproject.toml— addescalated-locale ~= 0.1escalated/locale_paths.py— new helper moduletests/settings.py— wireLOCALE_PATHS = get_locale_paths()tests/unit/test_locale_paths.py— coverage for the helperREADME.md— new "Translations (i18n)" sectionCHANGELOG.md— Unreleased entry