Skip to content

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

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

Ardnived merged 34 commits into
mainfrom
claude/a11y-strings-in-repo

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Strings only a screen reader speaks (aria-label, sr-only, live-region text) move out of SahajCloud into lib/i18n/a11y/<locale>.json. Each new key is machine-translated into every locale in the PR that adds it. Translators no longer see these strings, and a new one no longer needs a SahajCloud schema change, migration and type sync.
  • Call sites don't change. The server mounts the request locale's strings at <tab>.a11y, so t('media.a11y.play') resolves as before.
  • Covers all 60 keys of the ten a11y groups, plus three that open PRs were adding to SahajCloud: media.a11y.progress (from SahajCloud#1241, which is now closed), meditation.a11y.finder_region (feat(components): a MeditationLibrary for the meditations index block #293) and blocks.a11y.next_session (feat(components): count down to a live class and place the directory #321).

Change outline

 lib/i18n/a11y/
+  en.json          the English source: <tab>.<key>, 63 keys
+  context.json     what each key names, for whoever translates the next one
+  <locale>.json    17 machine-translated files: every SahajCloud locale except en and en-AU
+  a11y.ts          types, EN_A11Y, overEnglish(), withA11y(); English only, so the browser can import it
+  catalog.ts       every locale file. Server only: the strings reach the browser inside pageContext.translations
+  a11y.test.ts     each file has every key, its locale's own CLDR plural forms, and the English placeholders

 lib/i18n/web-translations.ts
+  SahajCloudWebTranslations   what the read returns
~  WebTranslations              SahajCloud's tabs plus the repo's `a11y` groups

 server/site-context.ts          loadTranslations
+  .then(withA11y(translations, a11yStringsFor(locale)))   runs last, after the English fallback

 server/routes/manifest.webmanifest, server/routes/oembed
+  withA11y(await getWebTranslations(…), a11yStringsFor(locale))   each mounts on its own read

 lib/i18n/i18n.ts                EN_TRANSLATIONS = snapshot + English a11y; createT and getT read WebTranslations, nothing wider
 lib/i18n/translations.en.json   the 10 `a11y` groups gone, as `sync:translations` writes it now SahajCloud#1246 has deployed
 AGENTS.md, docs/rules/rest-api.md   the rule: visible copy belongs to SahajCloud, screen-reader copy to this repo

Contract impact

Test results

  • Lean gate: ✓ .claude/skills/pr-prep/check.sh: lint, typecheck, and 1749 tests in 170 files.
  • Build: ✓ pnpm build. A probe string from hy.json appears in dist/server and nowhere in dist/client, so only the request's locale reaches the browser. Re-checked after /manifest.webmanifest and /oembed began importing the server-only catalog.
  • Watched failing first: removing media.progress from de.json and dropping %{platform} from blocks.share_on turn two a11y.test.ts cases red.

Manual verification

  1. On the preview, open /de/ and inspect a carousel's previous/next button. The aria-label should be German.
  2. Open /fr/ and check that the footer menu landmark's name is French.

Notes for reviewer

  • The translations are machine-made, deliberately. These strings reach few users and only need to be simple and functional. Grammar that depends on a placeholder (case endings in hu/tr/hy/ru, for example) is avoided with a colon form such as Megosztás: %{platform}, rather than guessing at an inflection.
  • en-AU has no file and reads English. a11y.test.ts requires a file for every other locale SahajCloud defines.
  • The English fallback keeps the visitor's screen-reader language. If the SahajCloud read fails on /de/, visible copy falls back to English but the aria-labels stay German.

🤖 Generated with Claude Code

Ardnived and others added 28 commits November 20, 2026 15:51
server/api-routes.ts held all four same-origin JSON routes. Each now lives
in the file its path names, so the folder is the route list:

  routes/api/related-meditations.ts      GET  /api/related-meditations/:lectureId
  routes/api/related-lectures.ts         GET  /api/related-lectures/:meditationId
  routes/api/submissions.ts              POST /api/submissions
  routes/api/live-preview/populate.ts    POST /api/live-preview/populate

What more than one route reads moves to _shared.ts (parseLocale,
relatedAnswer) and _proxy-failure.ts (upstreamRefusal,
reportProxyFailure). index.ts keeps registerApiRoutes, so entry.ts changes
by one import.

No behaviour changes: every handler body is moved verbatim, and every
existing test case is kept, split beside the file it covers. The new
index.test.ts fails a route registered outside the file its path names, a
route file that registers nothing, and a file index.ts does not register.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…wn files

Each route is now a folder at its path, holding route.ts, route.test.ts and
anything only it reads:

  related-meditations/route.ts       GET  /api/related-meditations/:lectureId
  related-lectures/route.ts          GET  /api/related-lectures/:meditationId
  submissions/route.ts, schema.ts    POST /api/submissions
  live-preview/populate/route.ts     POST /api/live-preview/populate

submissionSchema and SUBMISSION_BODY_LIMIT move from server/validation.ts
to submissions/schema.ts, since only that route reads them; the
zod-validation rule now also loads for a route's schema.ts. Top-level `_`
files stay for what several routes share.

index.test.ts now maps a path to `<path>/route.ts`, and also fails a file
that sits in no route's folder and is not a shared `_` file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
index.test.ts was a guard — a prose rule held by a test — sitting inside
the folder it audits, while the other twenty live in tests/guards/ with
shared plumbing in _source-scan.ts and two of them cited by AGENTS.md at
that path. Keeping this one next to its subject made a second convention
for the same kind of check.

It globs ../../server/routes/api/**/*.ts from there and strips that prefix
off each key, so a reported path still reads as the folder does. Checked
that it still fails on a stray file and on a misplaced route path.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXkzgLHTsVGKfpM6Gf
The section retold what the code and the guard already hold: the
path-to-file example, the register signature, and a last sentence listing
the three cases the guard fails on. A check that enforces a rule gets one
pointer, never its cases.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXkzgLHTsVGKfpM6Gf
parseLocale is isLocale plus a default, and both the narrowing and the
'en' it falls back to already live in sahajcloud-types.ts, where the
default is named DEFAULT_LOCALE. It is reusable there by name.

What stays behind is relatedAnswer, for the two related-* routes, so the
file takes their name: _shared said only that something shared it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXkzgLHTsVGKfpM6Gf
oembed-routes.ts and the related-* answer each held a byte-identical
'public, max-age=300, stale-while-revalidate=1800'. The split built the
shared owner for that value and left its twin next door, so both now read
JSON_CACHE_CONTROL from server/cache-headers.ts. The sitemap's longer one
stays where it is.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXkzgLHTsVGKfpM6Gf
submissions/schema.ts ended on a second newline. Lint went red once #313
set --max-warnings 0, which turns prettier/prettier into a failure.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWhMsP61j5GKkGuVZy
The mechanical half of the reorganisation, written by one script so any
branch can replay it:

- `@/` is the repo root (tsconfig `paths`, and the alias in vite, both
  vitest configs and Ladle), matching SahajCloud and SahajAtlasWeb.
  Imports leave a folder through `@/`; inside one they stay `./`.
- SahajCloud types leave server/: types/payload/payload-types.ts (the
  path SahajAtlasWeb uses), types/sahajcloud.ts, types/atlas.ts.
- The SahajCloud client and its transport move to server/sahajcloud/.
- oembed, sitemap.xml and manifest.webmanifest get route folders under
  server/routes/, like the /api routes.
- lib/ is grouped by topic: a11y, atlas, content, errors, forms, i18n,
  media, seo, sentry, urls (live-preview as before). The browser Sentry
  config moves from the repo root to lib/sentry/browser-config.ts, and
  AudioPlayer's shared playback types to lib/media/audio.ts.
- Each template gets its own folder; DESIGN_SYSTEM.md, STORYBOOK.md and
  MCP_USAGE.md move to docs/.

No code changes beyond import specifiers and the paths that name moved
files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…route has a folder

Everything the browser needed from server/ moves to lib/:

- the locale constants and rules → lib/i18n/locales.ts
- WEB_TRANSLATIONS_SELECT and WebTranslations → lib/i18n/web-translations.ts
- ErrorType, readStatus and detectErrorType → lib/errors/error-type.ts
- isCanonicalOrigin → lib/seo/canonical-origin.ts

With no browser importer left, error-utils.ts reports through
@sentry/cloudflare like the rest of server/, instead of @sentry/react.
The Ladle build therefore bundles no server/ module, so the Smoke
(ladle) WATCH list drops its server/ paths, and the guard now asserts
the bundle reaches none.

robots.txt, sitemap.xml and manifest.webmanifest each get their own
route folder (sitemap-routes.ts held all three), sharing
ROOT_FILE_CACHE_CONTROL from server/cache-headers.ts. server/routes/
index.ts registers every route, so entry.ts makes one call, and the
route-tree guard now covers the whole of server/routes/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…/sahajcloud/index.ts

client.ts held every read in 1,030 lines. It splits into pages, documents,
lectures, meditations, related, web-config and web-translations, with the
select/populate shapes in selects.ts and the shared options and preview
retry in query.ts. index.ts is the one entry point, so callers import
from '@/server/sahajcloud'; its test moves with it, unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rts nothing from server/

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… every path the moves changed

server/AGENTS.md now covers the route folders, the server-only boundary,
the submission proxy and Sentry; the SahajCloud read rules move to
server/sahajcloud/AGENTS.md, so they load where the reads are.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… replay it

scripts/reorg/ is temporary: it goes once no open PR predates this one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ews lib/sentry/

The generated-file note pointed at server/cms-types.ts, renamed away in
#131; app-specific SahajCloud types live in types/sahajcloud.ts. The
security-review trigger matched the root sentry.browser.config.ts, which
this PR moved to lib/sentry/, so it now names lib/sentry/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lated

Every string only a screen reader speaks moves out of SahajCloud's
wm-web-translations into lib/i18n/a11y/<locale>.json: the 60 keys of the
ten `a11y` groups, plus the three in-flight keys SahajCloud#1241, #1225 and
#1232 were adding (media.a11y.progress, meditation.a11y.finder_region and
blocks.a11y.next_session). English is the source; every other locale is
machine-translated, and a11y.test.ts refuses a gap, a wrong plural set or
a lost placeholder.

loadTranslations mounts the request locale's strings at <tab>.a11y over
whatever SahajCloud returns, so t('media.a11y.play') call sites are
unchanged and SahajCloud's old copies stop mattering before it drops them.
The English fallback keeps the visitor's screen-reader language. Only
English is imported where a browser can reach it; the other locales load
in the server-only catalog.

The snapshot and sync:translations drop every `a11y` group.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-web be52469 Commit Preview URL

Branch Preview URL
Nov 22 2026, 06:44 PM

@sydevs-bot

Copy link
Copy Markdown
Contributor

This PR is stacked on claude/reorg-layout. Merge it into that branch, or retarget it to main: the loop does not work stacked PRs, so nothing runs here until then.

🤖 sydevs dispatcher

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 22, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 22, 2026
@Ardnived
Ardnived enabled auto-merge November 22, 2026 18:27

@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 consumer half of a decision already merged upstream (SahajCloud#1246, 18:20Z), and the shape matches it: 63 strings, 17 locale files, one mount point, one test holding every file complete. The bulk is the locale count, not machinery; #1246 already answered build-vs-buy. The contract direction is verified: the mirror loses exactly the ten a11y groups, and Contract check (English mirror) passed at 18:22Z once #1246 deployed.

Two pieces are more than the change needs, and dropping both shrinks the diff.

Findings

  • should-fix lib/i18n/i18n.ts:156 — TranslationSource leaves two readers outside the mount.
  • should-fix lib/i18n/a11y/a11y.ts:50 — withA11y's Base is as with extra steps.
  • should-fix AGENTS.md:94 — retells a11y.test.ts's cases, and strands the eslint paragraph.
  • consider lib/i18n/a11y/catalog.ts:54 — RESOLVED memos less work than the spread beside it.
  • Body, no thread: the ⚠ still asks for a retarget once #327 merges; #327 is 5d6cbd9 and the base is main. And server/payload-types.ts is not a path here — the consumer copy is types/payload/payload-types.ts.

What was checked

Read whole on the branch: a11y.ts, catalog.ts, a11y.test.ts, web-translations.ts, i18n.ts, site-context.ts, en.json, context.json, both bare-read getT callers. Ladder walked for the 23 pieces new-pieces.mjs skipped: context.json earns its file, the 17 locale files are the approach, no dependency added. All 28 a11y. readers go through useT(), so finding 1 is latent, not live. git grep confirms #321's rename on claude/feat-309-live-session and #293's finder_region resolving. pluralize covers every category Intl gives the 17 locales. Streamliner: 16 covered, 10 kept; 3 sketches held, 1 dropped — it forces English plurals on every locale.

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


Generated by Claude Code

Comment thread lib/i18n/i18n.ts Resolved
Comment thread lib/i18n/a11y/a11y.ts Resolved
Comment thread lib/i18n/a11y/catalog.ts Resolved
Comment thread AGENTS.md 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 22, 2026
`Base` was only spread, and both call sites named it, so the generic
was a cast with extra steps. `base: object` takes any of them, which
also drops the `as unknown as` at the English snapshot and the return
annotation `loadTranslations` only carried to widen that `.then`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYkcPeZouAmCkwAWh1
`/manifest.webmanifest` and `/oembed` read SahajCloud directly, and the
`TranslationSource` union existed only so they could pass that read to
`getT`. It let an `a11y` key type-check at both and render as its key
path. They mount the locale's strings instead, so the accessor's type
says every string is present again.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYkcPeZouAmCkwAWh1
Memoing ten small group spreads sat beside `withA11y` spreading
thirteen whole tabs on every request, uncached. `loadTranslations`
already memos the whole result per request.

The two mount assertions compare by value, since the strings are no
longer one shared object per locale.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYkcPeZouAmCkwAWh1
The screen-reader bullet retold `a11y.test.ts`'s assertions, and this
file loads in every session. The `eslint-disable` paragraph governs
visible copy as much as spoken copy, so it sits above both bullets
rather than reading as the second one's tail.

`rest-api.md` names `withA11y` rather than `loadTranslations`, now
that two routes mount the strings as well.

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

Copy link
Copy Markdown
Contributor

Four critic threads, all adopted. No base merge needed: 4b5f852 already brought main in.

  • TranslationSource — both bare-read routes mount their own strings, so the union is gone. 817b1d0
  • withA11y's Base — one type parameter, two casts gone. 21b2bc8
  • RESOLVED — dropped; two assertions compare by value. 033e186
  • AGENTS.md — names the check, not its cases. be52469

Review body: the stale ⚠ is gone, and the consumer copy reads types/payload/payload-types.ts. The contract bullet records #1246 as merged and deployed.

Lean gate green: lint, types, 1749 tests in 170 files. pnpm build re-checked the boundary — an hy.json probe is in dist/server, not dist/client.

🤖 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 22, 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.

Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. 🤖 Written by the sydevs autonomous loop — see what this is

@Ardnived
Ardnived added this pull request to the merge queue Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 22, 2026
Merged via the queue into main with commit c7ec294 Nov 22, 2026
77 of 83 checks passed
@Ardnived
Ardnived deleted the claude/a11y-strings-in-repo branch November 22, 2026 18:47
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 22, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 22, 2026
#328 moved every screen-reader string out of the SahajCloud-owned global
into lib/i18n/a11y/, mounted at <tab>.a11y. It carries this branch's
blocks.a11y.next_session already, in context.json and all 20 locale files,
so the countdown's spoken sentence keeps its reader unchanged.

lib/i18n/translations.en.json takes main's side: the whole blocks.a11y
group goes, because that file is now the SahajCloud mirror alone. The
branch's own general.days and live_session keys auto-merged and stay.

types/payload/payload-types.ts drops the blocks.a11y.next_session
declaration this branch added. SahajCloud declares no a11y key, so a
string this repo owns must not be typed as one the CMS sends. The ten
a11y interfaces main's copy still carries are main's drift, left alone.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYr4Ykq7Pr8yom83KQ
sydevs-bot pushed a commit that referenced this pull request Nov 22, 2026
`main` #328 moved the screen-reader strings into `lib/i18n/a11y/`, so both
sides now wrap the English snapshot: this branch overlays the pending English
for SahajCloud#1225, `main` mounts the a11y catalog. Compose both, pending
first, since `withA11y` replaces each tab's `a11y` group wholesale.

#328 also ships `meditation.finder_region` in all eighteen locale files with
this branch's own English, so the two a11y halves of the overlay are dead:
drop the `PENDING_EN` entry and the `WmWebTranslationsMeditationA11YStrings`
augmentation. `MoodFinder` now reads the key translated rather than in English
everywhere. Both `shortcut:` markers stay — the visible `meditation.general`
keys are still pending upstream.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYAr7xtFrPM26Nt4Ej
sydevs-bot pushed a commit that referenced this pull request Nov 22, 2026
main's #329 re-ran `pnpm types:cms` against SahajCloud main (#1246), which
dropped the ten a11y interfaces and the video tab. This branch's hand copy
of the contract still carried them, so every one of those groups conflicted.

Resolved to main's generated output plus only the shapes this branch's code
needs from the unmerged sydevs/SahajCloud#1232: `blocks.live_session`,
`blocks.general.days`, `SplashBlock.event` and `ClassDirectoryBlock`. The
a11y groups stay dropped — #328 moved those strings into lib/i18n/a11y/,
so nothing here reads them from the CMS. `wisdom_sidetext` is re-typed
because its own `shortcut:` marker says a contract sync drops it until
sydevs/SahajCloud#1218 lands.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeQVCd9NZbNZ37XVL
sydevs-bot added a commit that referenced this pull request Nov 22, 2026
This branch dropped `LOCALES` because nothing read it. #328 then landed
`lib/i18n/a11y/a11y.test.ts` on main, which reads it to assert that every
locale SahajCloud defines has a screen-reader file. Neither side conflicts
textually, so the merge queue was the first run to typecheck the two
together and it failed there with TS2305 while the PR's own checks stayed
green.

The export is one line derived from `KNOWN_LOCALES`, so it costs nothing to
keep and the a11y gate needs it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZbEMkVnKuP6aRKfam
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