feat(i18n): consume central translations from @escalated-dev/locale#68
Merged
feat(i18n): consume central translations from @escalated-dev/locale#68
Conversation
…verrides
Loads translations from @escalated-dev/locale/locales/{locale}/ as the base
layer, then deep-merges this package's resources/lang/{locale}/messages.json
on top, then any host-supplied resources/lang/overrides/{locale}/ files.
Existing call sites (t('tickets.created')) keep working because messages.json
keys are hoisted to the top level.
Switch from npm range "^0.1.0" (no published npm package) to a GitHub tarball reference at v0.1.2, which ships the root package.json shim so the install resolves cleanly under Adonis 7 / Node 24.
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
Wires
escalated-adonisto consume translations from the new central npm package@escalated-dev/locale. The package's translation loader now layers three sources, with later layers winning on key conflict:@escalated-dev/locale/locales/{locale}/(canonical, shared across every host plugin)resources/lang/{locale}/messages.json(this package's existing files, kept as overrides)resources/lang/overrides/{locale}/messages.json(new per-host override slot)No translation content was modified. Existing call sites (
t('tickets.created')etc.) keep working because the loader hoistsmessages.jsonkeys to the top level for backwards compatibility.Wiring
package.json— added"@escalated-dev/locale": "^0.1.0"todependencies.src/support/i18n.ts— replaced the single-source loader with a layered loader that resolves the central package viacreateRequire, deep-merges the bundled local files on top, and finally deep-merges any host-supplied overrides underresources/lang/overrides/.stubs/config/i18n.stub— new stub that ships a canonicalconfig/i18n.tsfor host apps using@adonisjs/i18nv3+ directly. Chains twoloaders.fs(...)entries (central path resolved viarequire.resolve('@escalated-dev/locale/package.json'), thenapp.languageFilesPath()) in order so local resources override the central package.resources/lang/overrides/.gitkeep+README.md— new directory with documentation of the layering pattern and a sample@adonisjs/i18nconfig snippet.README.md/CHANGELOG.md— documented the new i18n source-of-truth.Blocked on escalated-dev/escalated-locale v0.1.0 publish
CI will fail on
npm installuntil@escalated-dev/locale@0.1.0is published to npm. Mark merge-ready once the upstream package ships. Expected error:The runtime loader already handles the missing-package case gracefully (
resolveCentralLangDir()returnsnulland the bundled local files are used alone), so local development without the published package keeps working.Test plan
npm installsucceeds once@escalated-dev/locale@0.1.0is publishednpm run build(ortsc) passesnode --test tests/*.test.jscontinues to pass — no translation regressionst('newKey')resolvesresources/lang/en/messages.json, verify the local value winsresources/lang/overrides/en/messages.json, verify the override wins