Skip to content

feat(i18n): consume central translations from escalated-locale#49

Merged
mpge merged 5 commits intomainfrom
feat/central-locale
May 2, 2026
Merged

feat(i18n): consume central translations from escalated-locale#49
mpge merged 5 commits intomainfrom
feat/central-locale

Conversation

@mpge
Copy link
Copy Markdown
Member

@mpge mpge commented May 2, 2026

Summary

Wire escalated-django to consume translations from the new central
escalated-locale
PyPI package while keeping the plugin-local escalated/locale/
directory as a higher-priority override layer.

  • Add escalated-locale ~= 0.1 to pyproject.toml runtime deps.
  • New helper escalated.locale_paths.get_locale_paths() composes a
    LOCALE_PATHS-compatible list with caller-supplied extras first,
    the plugin-local override next, and the central package last.
  • Wire the helper into tests/settings.py so CI exercises the
    override + central layering.
  • Document the wiring + override semantics in README and CHANGELOG.
  • Unit tests cover composition + graceful degradation when the
    central package is not yet installed.

Assumption flagged for escalated-locale

The central package must ship pre-compiled gettext artifacts at:

escalated_locale/locale/<lang>/LC_MESSAGES/django.po
escalated_locale/locale/<lang>/LC_MESSAGES/django.mo

These are required for Django's gettext-based translation system to
pick the catalogues up via LOCALE_PATHS. The canonical JSON shipped
by the central repo is not directly consumable by Django, so the
package's build step needs to also emit .po/.mo files (e.g. via
msgfmt during the wheel build). If escalated-locale chooses a
different layout, this PR's escalated/locale_paths.py::get_central_locale_path
will need a small tweak to point at the actual subdirectory.

Blocked on escalated-locale v0.1.0 PyPI publish

Expected CI failure: pip install -e ".[dev]" will fail in CI
with a Could not find a version that satisfies the requirement escalated-locale ~= 0.1 error until the central package is
published to PyPI. Marking this PR as draft until that lands.

Once escalated-locale 0.1.0 is published with the .po/.mo layout
above, CI should go green without further changes here.

Test plan

  • pytest tests/unit/test_locale_paths.py passes locally (4/4).
  • Full CI run after escalated-locale 0.1.0 publishes — expect
    green.
  • Smoke check: in a host project, install both packages, set
    LANGUAGE_CODE = "fr", and confirm a translated string from the
    central package renders. Then drop a same-key override into
    escalated/locale/fr/LC_MESSAGES/django.po and confirm it wins.

Files changed

  • pyproject.toml — add escalated-locale ~= 0.1
  • escalated/locale_paths.py — new helper module
  • tests/settings.py — wire LOCALE_PATHS = get_locale_paths()
  • tests/unit/test_locale_paths.py — coverage for the helper
  • README.md — new "Translations (i18n)" section
  • CHANGELOG.md — Unreleased entry

mpge added 4 commits May 1, 2026 22:10
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.
@mpge mpge marked this pull request as ready for review May 2, 2026 19:36
…/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.
@mpge mpge merged commit af14d03 into main May 2, 2026
9 of 10 checks passed
@mpge mpge deleted the feat/central-locale branch May 2, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant