feat(i18n): consume central translations from @escalated-dev/locale#53
feat(i18n): consume central translations from @escalated-dev/locale#53
Conversation
Adds the central locale package as a runtime dependency. The next commit wires it into the i18n loader as the BASE source, with local src/locales/ files retained as overrides until the central source is populated.
Wires useI18n() to consume @escalated-dev/locale as the canonical BASE translation source, with src/locales/*.json now treated as local plugin overrides that win over central. Lookup order: 1. host-app customMessages (current locale) 2. local override (src/locales/<lang>.json) 3. central source (@escalated-dev/locale) 4. host-app customMessages (en fallback) 5. local override (en fallback) 6. central source (en fallback) 7. raw key Public API is unchanged: components still call useI18n().t(key, repl) and $t works identically. No translation strings are modified by this commit — Codex will populate the central package separately, after which the local override files can be trimmed. Blocked on @escalated-dev/locale v0.1.0 publish; CI npm install will fail until then.
Clarifies that the JSON files in src/locales/ are now local overrides that win over the central @escalated-dev/locale source, and explains the resolution order used by useI18n().t().
Blocked on npm publishThis PR is intentionally staying as draft until Why we can't consume from GitHub directlynpm supports git-source dependencies (e.g. npm has no first-class way to point a git-source dep at a subdirectory (no What needs to happen to unblockPer the registry checklist at
Once Note on other ecosystemsMost other host plugins (Composer/Packagist via Leaving as draft. No code changes required on this branch — flipping to "Ready for review" after publish should be sufficient. |
The central package's root package.json shim landed at v0.1.2 in escalated-dev/escalated-locale, making github tarball deps resolve cleanly. This unblocks the central-locale PR; once @escalated-dev/locale publishes to the npm registry this can revert to a semver range.
Summary
Wires this frontend to read translations from the central source (
escalated-dev/escalated-locale) with override fallback.Blocked on
escalated-dev/escalated-localev0.1.0 publish. CI will fail until then (npm install cannot resolve@escalated-dev/locale@^0.1.0).After v0.1.0 publishes, mark this PR ready and CI should go green.
Pattern
useI18n().t(key, replacements)(and the$tshim used in templates) now resolves a key through this layered chain:customMessagesfor the current locale (mergeMessages(locale, msgs)from a host app — top priority).src/locales/<lang>.json— this repo's existing JSON files, retained AS overrides so any string this plugin phrases differently still wins over central).@escalated-dev/locale— the canonical base layer).en).The public composable API is unchanged — every component that calls
useI18n()keeps working without edits. No translation strings are modified by this PR.Why retain
src/locales/*.jsonas overrides?Per the rollout plan, Codex will populate
@escalated-dev/localewith canonical strings sourced from THIS repo (it is the authoritative origin). Until that consolidation lands, keeping the local JSON files in place means the layered chain still finds every key — there is no UI regression while the central package is empty / partial. After Codex finishes, the local files can be trimmed (or deleted) so the central source becomes the sole source for any key not specifically overridden by this plugin.Files changed
package.json— add@escalated-dev/locale^0.1.0todependenciessrc/composables/useI18n.js— three-tier lookup (host customMessages → local overrides → central) with English fallback in the same ordersrc/locales/README.md— new, documents the override layeringCHANGELOG.md— Unreleased entryTest plan
@escalated-dev/localev0.1.0 to publish on npmde) still produces translated stringsmergeMessages('en', {...})call still wins over both layersExpected CI failure
npm ci/npm installwill fail with404 Not Found - GET https://registry.npmjs.org/@escalated-dev%2flocale - Not found(or equivalent) until the central package publishes v0.1.0. This PR is intentionally a draft for that reason.