Skip to content

refactor(i18n): screen-reader strings live in the repo, machine-translated - #456

Merged
Ardnived merged 7 commits into
mainfrom
refactor/a11y-strings-in-repo
Nov 22, 2026
Merged

Ardnived merged 7 commits into
mainfrom
refactor/a11y-strings-in-repo

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The 13 strings the widget only ever speaks move out of SahajCloud's sy-atlas-translations into src/config/a11y/<locale>.json, under new <group>.a11y.<key> names. They are machine-translated into every SahajCloud locale, and any key added later gets translated in the PR that adds it. Translators no longer see these strings, and a new one needs no SahajCloud change.
  • English is mounted into the boot resource. Every other locale's file is a lazy chunk, which translationsQuery mounts onto that locale's SahajCloud bundle. The eager payload stays within pnpm size.
  • Visible copy is unchanged and still comes from SahajCloud. A string that is both seen and spoken (common.chrome.close, filters.*.label, widget_label) stays there.

Change outline

 src/config/a11y/
+  en.json, context.json, <17 locales>.json    13 keys each
+  a11y.ts         withA11y(), loadA11yStrings(): an import.meta.glob of lazy chunks, English for a locale with no file
+  a11y.test.ts    every SahajCloud locale has a file (type-checked against Config['locale']), every key, the English placeholders

 src/config/api/fetch.ts        translationsQuery → getLocaleBundle: SahajCloud bundle + that locale's a11y chunk
                                a chunk that fails to load is reported, and its keys fall back to English
 src/config/i18n.ts             boot resource = withA11y(snapshot, EN_A11Y)
 src/types/i18next.d.ts         t() keys = typeof snapshot & MountedA11y

 renamed call sites (19 files, tests included)
   calendar.{previous,next,pick_date}           → calendar.a11y.*
   common.chrome.{explore,loading}              → common.a11y.*
   common.settings.title                        → common.a11y.settings
   event.actions.{view_photo,pause_slideshow}   → event.a11y.*
   filters.chrome.remove                        → filters.a11y.remove
   search.results.showing                       → search.a11y.results_showing
   search.nearby_prompt.dismiss                 → search.a11y.dismiss_nearby_prompt
   share.{copy_link,share_on}                   → share.a11y.*

 src/config/translations.en.json   unchanged — it is generated, and `sync:translations` drops the 13 keys once SahajCloud does
 src/config/translations.test.ts   both directions now read the snapshot with the English a11y strings mounted
                                   RETIRING_KEYS names the 13 unwired keys against sydevs/SahajCloud#1246

Contract impact

  • Host-observable, but needs no host change. On a non-English page the widget fetches one more small chunk from its own origin, which the existing script-src already covers. CHANGELOG.md and the script-src row in docs/embedding.md say so.
  • SahajCloud goes first. refactor(translations): no global declares a screen-reader-only string SahajCloud#1246 removes the 13 keys, and this merges after it. In between, the deployed widget falls back to its bundled English for those keys. After it, pnpm sync:translations reproduces this PR's snapshot.
  • src/types/payload/ is untouched. The next pnpm types:cms after SahajCloud#1246 drops the keys from SyAtlasTranslation, and since every key in that type is optional, satisfies keeps holding.

Test results

  • Lean gate: ✓ .claude/skills/pr-prep/check.sh --full: lint, typecheck, the unit lane, the build and pnpm size (within budget).
  • The review revision re-ran the lean gate (lint, typecheck, 2356 unit tests). The build and pnpm size are CI's.
  • Build: dist/assets/de-*.js holds the German strings, outside the eager graph.
  • Watched failing first: removing calendar.next from fr.json and dropping %{platform} from share.share_on turn two a11y.test.ts cases red, and the new translationsQuery spec fails with the mount reverted.

Manual verification

  1. On the preview, open /?locale=de, open the calendar, and inspect the arrow buttons. Their aria-labels should read "Zurück" and "Weiter".
  2. In the Network panel, the switch to German fetches one de-*.js chunk.

Notes for reviewer

  • These keys sat outside any a11y group in SahajCloud. I found them by tracing every t() call into an aria-label, srLabel, closeLabel or sr-only sink, then dropped any key that also renders as visible text.
  • The translations are machine-made, deliberately. Grammar that depends on a placeholder (case endings) is avoided with a colon form, such as Поделиться: %{platform}.

🤖 Generated with Claude Code

Ardnived and others added 2 commits November 20, 2026 20:21
…lated

The thirteen keys the widget only ever speaks — the calendar arrows and
date input, the drawer toggle, the loading spinners, the settings cog, the
carousel's photo and pause buttons, the filter chip's remove button, the
results announcement, the nearby prompt's dismiss button and the share
buttons — move out of SahajCloud's sy-atlas-translations into
src/config/a11y/<locale>.json, renamed to <group>.a11y.<key>. English is
the source; every other SahajCloud locale is machine-translated, and
a11y.test.ts refuses a missing locale, key or placeholder.

English is mounted into the boot resource. Every other locale's file is a
lazy chunk that translationsQuery mounts onto its SahajCloud bundle, so the
cache, the warm-up and applyLocale hold one tree and the eager payload
stays inside its budget. A chunk that fails to load is reported and leaves
those keys to English rather than the whole language.

The snapshot drops the thirteen old keys, as the sync will once SahajCloud
removes them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-bot

sydevs-bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 04:13Z address-review · attempt 1 · session · done
  • 04:13Z address-review · attempt 1 · session
  • 04:01Z review-pr · attempt 1 · session · done
  • 04:01Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 21, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 21, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The mechanics are clean and the classification holds: all 13 keys trace to an aria-label, srLabel, closeLabel or an sr-only region, none with a second visible sink. What the code does not explain is why they had to move. SahajCloud already has a first-class a11y sub-group for screen-reader-only copy — collapsed, labelled "Accessibility" — in 10 wm-web-translations tabs and zero Atlas ones. Adopting it there answers the stated problem with no module, no 19 files, no lazy chunk, no two-repo deploy order, and keeps human translators on the copy blind users hear. That makes most of this diff unnecessary, so settle it first. It also claims a11y as a repo-owned key segment while that is already the producer's slug for the same concept; views/shared.tsx:199 shows the cost — one button's two aria-labels, now one human and one machine.

Findings

  • blocker — the approach → a11y.ts:14
  • should-fix — snapshot hand-edited; RETIRING_KEYS exists → translations.en.json:2
  • should-fix — Streamline: unreachable base-tag branch → a11y.ts:51
  • consider — Streamline: A11yStrings → a11y.ts:17
  • consider — dead defaultValue guards → views/fallbacks.tsx:264

What was checked

Read whole: a11y.ts, a11y.test.ts, en.json, context.json, fetch.ts's translation region, locale.ts, i18n.ts, i18next.d.ts, translations.test.ts, 19 call sites; producer translationsField.ts, both schemas. Verified that no old key survives, that preferredLocale narrows the tag, that Config['locale'] covers every offered locale, and that the change outline, the contract claims and the CSP row match the diff. Streamliner: 8 pieces, 5 kept, 2 posted; dropped folding getLocaleBundle into getTranslations, which conflates the wire fetcher wire.test.ts pins. No question threads. Profile read.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/config/a11y/a11y.ts Resolved
Comment thread src/config/translations.en.json Resolved
Comment thread src/config/a11y/a11y.ts Resolved
Comment thread src/config/a11y/a11y.ts Resolved
Comment thread src/views/fallbacks.tsx Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 21, 2026
`src/config/translations.en.json` is generated by `pnpm sync:translations`, and
deleting the 13 keys by hand pre-empts the sync that drops them. A sync run
before sydevs/SahajCloud#1246 deploys would re-add them, and the snapshot's
reverse direction would then fail naming 13 keys nothing references.

`RETIRING_KEYS` already owns this window: a key leaves the app a whole release
before it can leave the snapshot. Restore the generated file and name all 13
there, against the SahajCloud ticket that removes them.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW5ZKbJZHBcppnaY8H
`a11yFileFor`'s base-tag fallback was a third copy of a narrowing `preferredLocale`
has already done: it resolves a requested tag against the offered set before the
bundle is keyed (`config/i18n-options.ts`), and `a11y.test.ts` requires a file for
every locale that set can hold. The only tag that reaches the branch is a verbatim
`?locale=de-AT`, whose query key `applyLocale` never reads.

Fold the lookup into `loadA11yStrings`. The exact file and the English fallback
are unchanged, and the two surviving cases cover both.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW5ZKbJZHBcppnaY8H
Nothing imported it, and `EN_A11Y: A11yStrings = en` annotated what `typeof en`
already infers. `MountedA11y` was its one reader, so it maps over `typeof en`
directly. The module prose moves to a file header, where it was describing the
module rather than the alias.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW5ZKbJZHBcppnaY8H
`common.a11y.loading` cannot miss. `config/i18n.ts` mounts `EN_A11Y` into the boot
resource, and `a11y.test.ts` refuses a missing or blank value in any locale's file,
so each guard was unreachable — and the three spelled it three ways ("Loading…",
"Loading", "Loading…"), which only a dead guard can get away with.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW5ZKbJZHBcppnaY8H
`Spinner` renders `srLabel` only under `!label && !decorative`, so a decorative
spinner inside an `aria-hidden` curtain announced nothing — the comment above it
says that is the intent. Translating a string nothing reads was the last reason
this module called `useTranslation`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW5ZKbJZHBcppnaY8H
@sydevs-bot

Copy link
Copy Markdown
Contributor

Review addressed

Four adopted, one back to you.

Adopted

Open — yours to settle

  • The approach. What the upstream a11y sub-group does not answer: an untranslated key is absent there, so fallbackLng speaks English. Options A and B in the thread, and it holds the merge.

Lean gate green.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 21, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 21, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design c776345 Nov 21 2026, 04:29 AM

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. Enable auto-merge when you want it merged: the queue tests it against its base. 🤖 Written by the sydevs autonomous loop — see what this is

@Ardnived
Ardnived enabled auto-merge November 22, 2026 18:08
@Ardnived
Ardnived added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 093532f Nov 22, 2026
34 checks passed
@Ardnived
Ardnived deleted the refactor/a11y-strings-in-repo branch November 22, 2026 18:14
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 22, 2026
Ardnived added a commit that referenced this pull request Nov 26, 2026
sydevs/SahajCloud#1268 serves the inline embed's three strings and no
longer serves `compact.open`, so a full `pnpm sync:translations --write`
runs clean here. The hand-added `common.map.expand`, `common.map.close` and
`countries.place_title` already matched production byte for byte.

The sync also drops the thirteen screen-reader keys SahajCloud#1246
removed, which `RETIRING_KEYS` held since #456 moved them into
`src/config/a11y/`; their entries go with them. `common.errors.captcha_blocked`
stays retiring until SahajCloud#1278. `pnpm types:cms` wrote no change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants