test(i18n): make the pseudo-locale oracle read attribute copy (#2211)
Co-authored-by: Kandev Agent <agent@kandev.dev> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+62
-19
@@ -424,33 +424,76 @@ One thing it shows you is **not** a miss: an interpolated API or network payload
|
||||
stays English by design, so it renders unaccented and is still correct. See
|
||||
[the interpolated-value limit](#and-it-is-weakest-at-an-interpolated-value).
|
||||
|
||||
Three things it cannot show you at all — the second and third are detailed below:
|
||||
Two things it cannot show you at all — the second is detailed below:
|
||||
|
||||
1. **Module-scope `t()`.** That copy *is* translated, just frozen at the boot
|
||||
locale, so it renders accented and looks correct while never responding to a
|
||||
switch. `check-module-scope-t.mjs` is what catches it.
|
||||
2. **Copy that never becomes a text node** — an attribute string leaves no trace
|
||||
on screen at all.
|
||||
3. **An un-migrated value interpolated into a migrated frame** — it renders
|
||||
2. **An un-migrated value interpolated into a migrated frame** — it renders
|
||||
inside accented copy and reads as done.
|
||||
|
||||
### It cannot see copy that is not a text node
|
||||
A third used to belong on that list — copy that never becomes a text node — and
|
||||
the spec now reads it directly. That pass is described next, because what it does
|
||||
*not* check still matters when you migrate.
|
||||
|
||||
`findUnlocalizedText` in `e2e/tests/i18n/pseudo-coverage.spec.ts` walks
|
||||
`NodeFilter.SHOW_TEXT`, and a human looking at the screen is no different:
|
||||
**copy carried in an attribute — `aria-label`, `aria-description`, `title`,
|
||||
`placeholder`, `alt` — renders nothing visible and leaves no trace under
|
||||
pseudo.** The Settings → System → Storage review demonstrated it by reverting an
|
||||
`aria-label` to an English template literal; nothing failed.
|
||||
### It reads attribute copy, which nothing on screen shows you
|
||||
|
||||
The guard is the primary defence here, not the oracle: those five attributes are
|
||||
in `jsx-attributes.include`, so on an allowlisted path the lint rule does flag
|
||||
them. The consequence is that for attribute copy there is **no second check** — on
|
||||
a path not yet allowlisted, or for a fragment the `words.exclude` patterns skip,
|
||||
nothing downstream catches it. The copy only screen-reader users receive is
|
||||
therefore the copy with the weakest safety net. Read attribute props by eye when
|
||||
you migrate, and prefer a `t()` call over a template literal in them so the value
|
||||
stays greppable.
|
||||
**Copy carried in an attribute — `aria-label`, `aria-description`, `title`,
|
||||
`placeholder`, `alt` — renders nothing visible, so a human eyeballing the
|
||||
pseudo-locale can never catch it.** The Settings → System → Storage review
|
||||
demonstrated the gap by reverting an `aria-label` to an English template literal:
|
||||
nothing failed.
|
||||
|
||||
`findUnlocalizedCopy` in `e2e/tests/i18n/pseudo-coverage.spec.ts` therefore runs a
|
||||
second pass over `document.querySelectorAll("[aria-label],…")` alongside the
|
||||
`NodeFilter.SHOW_TEXT` walk, applying the same accented/word-like tests and the
|
||||
same allowlist stripping. Findings name the attribute and the element that carries
|
||||
it, since a bare string gives you nowhere to look:
|
||||
|
||||
```text
|
||||
aria-label on button#language-select: "Display language (pseudo)"
|
||||
```
|
||||
|
||||
**Read the control line before you trust a green screen.** A migrated attribute
|
||||
renders as `Mōŕē ĩńfōŕmàţĩōń`, which has no 4-letter ASCII run and so is dropped
|
||||
at the `wordlike` gate before the accented test ever sees it. Soundness is fine —
|
||||
a real miss is pure ASCII — but it means a working pass and a pass whose selector
|
||||
matched *nothing* produce the same empty output. One agent scanning by hand
|
||||
concluded their scan was broken on exactly this. The spec therefore asserts
|
||||
`inspectedAttributes > 0` per screen, prints how many rendered fully accented, and
|
||||
pins accent detection once against `#language-select`'s known-migrated
|
||||
`aria-label`. If you scan by hand, emit a known-migrated attribute as your own
|
||||
positive control.
|
||||
|
||||
Four things about that pass are deliberate, and worth knowing before you read its
|
||||
output:
|
||||
|
||||
- **It does not reuse the text pass's zero-size-rect check.** A visually hidden
|
||||
control with an `aria-label` is the exact case the pass exists to catch, and
|
||||
every `sr-only` node measures as good as zero. It uses `checkVisibility()`
|
||||
instead — `display: none`, `visibility: hidden` and skipped `content-visibility`
|
||||
subtrees are dropped, because then nobody receives the label; opacity and
|
||||
off-screen positioning are kept, because the accessibility tree keeps them.
|
||||
- **An empty value is never reported.** `alt=""` is load-bearing markup — it marks
|
||||
an image as decorative so screen readers skip it — and flagging it would push
|
||||
authors into writing alt text for spacers.
|
||||
- **Findings are keyed by attribute and value, not by element**, with a `(×N)`
|
||||
count. One un-migrated shared component rendered on twenty rows would otherwise
|
||||
bury every other string on the screen.
|
||||
- **One accented character does not clear an attribute**, unlike the text pass.
|
||||
An `aria-label` built as `` `Collapse ${label}` `` renders `Collapse Ĝēńēŕàĺ` —
|
||||
an un-migrated English *frame* around a migrated value, which accent-clears-all
|
||||
would call done. Allowlist stripping is what separates that from the legitimate
|
||||
case, where the ASCII fragment is allowlisted *data* rather than the frame
|
||||
(`Àćţĩōńś ƒōŕ Agent` on the layouts screen strips to nothing). Such findings are
|
||||
tagged `— English frame, migrated value`.
|
||||
|
||||
The guard is still the primary defence: those five attributes are in
|
||||
`jsx-attributes.include`, so on an allowlisted path the lint rule flags the
|
||||
literal before it ever renders. The oracle is the second check that attribute copy
|
||||
previously had none of — on a path not yet allowlisted, or for a fragment the
|
||||
`words.exclude` patterns skip. Prefer a `t()` call over a template literal in an
|
||||
attribute either way, so the value stays greppable.
|
||||
|
||||
### …and it is weakest at an interpolated value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user