fix(locale): English fallback for unconfigured consumers (WCAG 4.1.2)#276
Open
sridhar-3009 wants to merge 1 commit into
Open
fix(locale): English fallback for unconfigured consumers (WCAG 4.1.2)#276sridhar-3009 wants to merge 1 commit into
sridhar-3009 wants to merge 1 commit into
Conversation
Adds @vuetify/v0/locale/messages/en subpath export with English strings for all component aria keys. createLocaleFallback now returns meaningful English text instead of raw key strings, ensuring aria-labels are human-readable even when no locale plugin is installed. - Add packages/0/src/locale/messages/en/index.ts with all component strings - Add ./locale/messages/en conditional export to package.json - createLocaleFallback: t(key) now looks up English strings via lookupEn() - Add onMissing hook to LocaleOptions / LocaleAdapterContext / V0LocaleAdapter - Update component tests that expected raw key fallback to expect English strings
|
commit: |
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.
Problem
When
useLocale()is called without a locale plugin (e.g.createLocalePlugin()not installed),createLocaleFallbackreturned the raw dot-notation key as the string — e.g.t('Dialog.close')→'Dialog.close'. This violates WCAG 4.1.2 (Name, Role, Value): screen readers announce"Dialog.close"instead of a human-readable label.Closes #196
Solution
Add an
@vuetify/v0/locale/messages/ensubpath export containing all English component strings.createLocaleFallbacknow looks up keys against that dictionary and returns the English translation, sot('Dialog.close')→'Close'even with no locale plugin.Also adds an
onMissinghook toLocaleOptions,LocaleAdapterContext, andV0LocaleAdapter, giving configured consumers a way to supply custom fallbacks when a key is missing from their locale.Changes
packages/0/src/locale/messages/en/index.ts— new: English strings for all component aria keyspackages/0/package.json— add./locale/messages/enconditional exportpackages/0/src/composables/useLocale/index.ts—createLocaleFallbackuseslookupEn()+_interpolate(); addonMissingtoLocaleOptionspackages/0/src/composables/useLocale/adapters/adapter.ts— addonMissing?toLocaleAdapterContextpackages/0/src/composables/useLocale/adapters/v0.ts— callonMissingbefore raw-key fallbackpackages/0/src/composables/useLocale/index.test.ts— 9 new tests:onMissinghook,createLocaleFallbackEnglish defaultsTest plan
pnpm test:run— 151 files, 6110 tests passpnpm typecheck— no errorspnpm repo:knip— no unused exportst('Dialog.close')→'Close';t('Pagination.status', { page: 2, pages: 10 })→'Page 2 of 10'onMissingfires only for missing keys after fallback chain