Skip to content

fix: English aria-label fallbacks when locale keys are unresolved (#196)#254

Open
johnleider wants to merge 1 commit into
masterfrom
fix/locale-aria-fallback
Open

fix: English aria-label fallbacks when locale keys are unresolved (#196)#254
johnleider wants to merge 1 commit into
masterfrom
fix/locale-aria-fallback

Conversation

@johnleider
Copy link
Copy Markdown
Member

Closes #196.

Problem

Components emit user-facing strings (aria-label, aria-valuetext, live-region text) via locale.t(key). v0 ships no default message bundle, so when no locale is configured — the out-of-box default — t() returns the key verbatim. Screen readers then announce dotted keys like "Dialog dot close", "Pagination dot next" across ~16 components. That's a WCAG 4.1.2 (Name, Role, Value) defect in the default configuration.

Fix

Each call site coalesces to a concise English default when t() returns the key unchanged:

const close = locale.t('Dialog.close')
// aria-label:
close === 'Dialog.close' ? 'Close' : close

This is the per-component default approach already established in AvatarIndicator (translated === LABEL_KEY ? \+${count}` : translated) — not a new mechanism. It deliberately avoids the two previously-rejected approaches: it does **not** add a fallback parameter to t()`, and it does not ship a default message bundle. A consumer-supplied locale always overrides; the English default is only the out-of-box accessibility floor.

Interpolated keys (Carousel slide counts, Pagination page numbers, Rating value text, the Pagination/Carousel live regions) keep their interpolation in the fallback.

Scope

  • ~16 components across Dialog, AlertDialog, Snackbar, NumberField, Button, Rating, Breadcrumbs, Pagination (incl. live status), Carousel (incl. live region)
  • PHILOSOPHY.md §5.5 updated to document the fallback as the accessibility floor
  • Breadcrumbs / NumberField / Pagination tests updated — they previously selected elements by, or asserted equality with, the raw key (which also violated the documented "assert toBeDefined(), not exact text" rule)

…olved

Components route user-facing strings (aria-label, aria-valuetext, live-region text) through locale.t(). With no locale messages configured, t() returns the key verbatim, so labels degraded to dotted keys like "Dialog.close" — a WCAG 4.1.2 defect in the default configuration.

Each site now coalesces to a concise English default when t() returns the key unchanged, matching the pattern already used in AvatarIndicator. A consumer-supplied locale still overrides. Updates PHILOSOPHY 5.5 and the Breadcrumbs/NumberField/Pagination tests that pinned to or selected by the raw key.

Closes #196
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 1, 2026

Open in StackBlitz

commit: d46013e

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.

[Bug Report] locale.t() needs a key-level fallback — WCAG 4.1.2 gap

1 participant