Skip to content

feat(i18n): consume central translations from :escalated_locale#62

Draft
mpge wants to merge 1 commit intomasterfrom
feat/central-locale
Draft

feat(i18n): consume central translations from :escalated_locale#62
mpge wants to merge 1 commit intomasterfrom
feat/central-locale

Conversation

@mpge
Copy link
Copy Markdown
Member

@mpge mpge commented May 2, 2026

Summary

Wires escalated-phoenix to consume its translation catalogs from the new central :escalated_locale Hex package so every Escalated host plugin (Phoenix, Laravel, Rails, Django, …) ships an identical message set.

  • Adds {:escalated_locale, "~> 0.1"} (and explicit {:gettext, "~> 0.24"}) to mix.exs deps.
  • Introduces Escalated.Gettext — a Gettext backend (use Gettext.Backend) that:
    • re-exports the canonical catalogs shipped by :escalated_locale, and
    • merges any per-host overrides found under priv/gettext/overrides/{locale}/LC_MESSAGES/escalated.po.
  • Adds priv/gettext/overrides/.gitkeep so the override path exists out-of-the-box.
  • Documents the translation workflow in README + CHANGELOG.

Assumption about :escalated_locale

This PR assumes the central package ships .po files at:

priv/gettext/{locale}/LC_MESSAGES/escalated.po

…and exposes a Gettext backend module (e.g. EscalatedLocale.Gettext). The Escalated.Gettext backend in this repo is wired so that local overrides take precedence over the central catalog, with no need for the host application to depend on :escalated_locale directly.

If the published package ends up using a different domain name or path, the priv: option / domain on Escalated.Gettext is the only place that needs to change.

Why Gettext when this plugin previously used priv/locales/*.json

The existing priv/locales/{ar,it,ja,…}.json files are consumed by the shared @escalated-dev/escalated Vue frontend over Inertia and are intentionally left untouched in this PR. A follow-up will migrate them to be sourced from :escalated_locale as well (likely by exporting JSON alongside .po from the central package, or by generating JSON from the .po at compile time).

Blocked on :escalated_locale v0.1.0 Hex publish

CI is expected to fail at mix deps.get until escalated_locale v0.1.0 is published to Hex. Marking as draft until then.

Once :escalated_locale is on Hex:

  1. mix deps.update escalated_locale
  2. CI should turn green with no further changes here.
  3. Move out of draft.

Files changed

  • mix.exs — added :gettext and :escalated_locale deps; included CHANGELOG.md in package files.
  • lib/escalated/gettext.ex — new Gettext backend with override path.
  • priv/gettext/overrides/.gitkeep — placeholder so the override path exists.
  • README.md — new "Translations" section.
  • CHANGELOG.md — Unreleased / Added entry.

Test plan

  • Wait for :escalated_locale v0.1.0 to land on Hex.
  • Re-run CI — mix deps.get and mix compile should both succeed.
  • Verify Gettext.gettext(Escalated.Gettext, "Open") resolves to the upstream string.
  • Drop a stub override at priv/gettext/overrides/en/LC_MESSAGES/escalated.po and confirm it wins over upstream.
  • Confirm mix hex.build includes priv/gettext/overrides only (not the upstream catalogs).
  • Mark PR ready for review and merge.

Wire the Phoenix host plugin to pull its translation catalogs from the
shared `:escalated_locale` Hex package so every Escalated host plugin
ships the same message set.

- Add `{:escalated_locale, "~> 0.1"}` (and explicit `:gettext`) to deps
- Introduce `Escalated.Gettext` backend that re-exports the central
  catalogs and reads per-host overrides from `priv/gettext/overrides`
- Add `priv/gettext/overrides/.gitkeep` so the override path exists out
  of the box
- README + CHANGELOG document the new translation workflow

Translation contributions should now go to escalated-dev/escalated-locale
rather than this repo. Existing `priv/locales/*.json` catalogs (used by
the shared Vue frontend) remain untouched in this PR.
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