feat: decouple component library from vue-i18n#1186
Draft
Arnold Stoba (arnoldstoba) wants to merge 2 commits into
Draft
feat: decouple component library from vue-i18n#1186Arnold Stoba (arnoldstoba) wants to merge 2 commits into
Arnold Stoba (arnoldstoba) wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
5594b8c to
d0f42bc
Compare
d0f42bc to
3fae5f6
Compare
3fae5f6 to
fba7d8f
Compare
Make the component library translation-solution agnostic. Components now use an internal i18n layer (useMeteorI18n + createMeteorI18nPlugin) with an optional host adapter, bundled English/German snippets, a reactive locale, and predictable fallbacks: host adapter -> override registry -> bundled locale -> bundled English -> key. - Remove the hard vue-i18n dependency and externalization (resolves the version conflict from #1070; nothing in the bundle imports vue-i18n anymore) - Public snippet keys are namespaced mt.<component>.<key> - Hosts/plugins can override snippets and add languages, seamlessly: host-first in the Admin (translate mt.* like any admin snippet) or via createMeteorI18nPlugin({ messages }) - Locale fallback chain (de-DE -> de -> en, en-US -> en); region variants share the language default, region-specific overrides win - createVueI18nAdapter helper accepts a createI18n instance or a composer (@nuxtjs/i18n) - Migrate 34 components; the mt-text-editor cluster shares one catalog - Update tests, Storybook (en/de locale toggle), README, developer docs, and example apps The create-meteor-extension scaffold keeps the published-compatible setup; it will be updated to the new i18n API once 6.0.0 is published (its CI test installs from the registry). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a Playwright test that exercises the full chain in a real consumer app (createMeteorI18nPlugin + createVueI18nAdapter + reactive host locale): - bundled EN snippets by default, switch to bundled DE on locale change - region variants share the language default (en-US -> en) - a region-specific override (en-GB -> mt.pagination.infoText) wins for en-GB only - non-overridden keys still fall back to bundled en even at en-GB - the en-GB override does not leak to en-US / en The demo surface is gated behind ?i18n=1 so the default page (and the existing smoke-test screenshot) is unchanged. Runs in the existing "Playwright Integration Tests" CI job. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ab294cb to
38412fe
Compare
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.
Closes #1070
What?
Make the component library translation-solution agnostic: it no longer depends on
vue-i18n. Components use an internal i18n layer with an optional host adapter, bundled EN/DE snippets, a reactive locale, and predictable fallbacks. Hosts and plugins can now override Meteor snippets and add languages.Why?
Meteor declared
vue-i18n@^9as a hard dependency. This forced a specific library and version on every consumer. Apps on a newervue-i18n(e.g. the Admin on v10, a Nuxt app on@nuxtjs/i18n) ended up with twovue-i18ninstances — Meteor'suseI18n()resolved a different instance than the host's, breaking translations.We chose an internal layer + adapter (over simply bumping
vue-i18n) because it removes the forced dependency entirely and is the only way to be truly version- and library-agnostic. It also unlocks snippet overriding/extension, which the old per-component local scope did not allow.How?
vue-i18nfrom dependencies and the build externals (nothing in the bundle imports it anymore).useMeteorI18n+createMeteorI18nPlugin({ adapter?, messages? })(source undersrc/i18n/). Resolution order: host adapter → override registry → bundled locale → bundled English → key, with a locale fallback chain (de-DE → de → en,en-US → en).mt.<component>.<key>so hosts/plugins can target them.createVueI18nAdapter(accepts acreateI18ninstance or a composer, so it also works with@nuxtjs/i18n).Testing?
lint:all,lint:types, and the production build all pass; the bundle contains 0vue-i18nimports.shopware/shopware.Anything Else?
Consumer migration
Zero setup now works — components render bundled English out of the box and no longer throw without
vue-i18n:To drive the locale reactively / let your app provide translations, install the plugin:
Override wording / add a language (host-first, or via the registry):
💥 Breaking changes
vue-i18nis no longer a dependency. Meteor no longer installs it for you; if your app uses it, declare it yourself.vue-i18ninstance. To get non-English / reactive locale in Meteor components you must installcreateMeteorI18nPlugin(with an adapter). Without it, Meteor renders English instead of throwing.mt-→mt.):mt-field-error.* → mt.field-error.*,mt-text-editor*.* → mt.text-editor*.*,mt-action-menu-item.* → mt.action-menu-item.*. Plugins overriding these must update the key path. The Admin'sglobal.error-codes.*keys are unchanged.