Repository navigation
refactor(i18n): screen-reader strings live in the repo, machine-translated - #328
Conversation
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]>
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXrfyf1t8Nft3uZch7
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXrfyf1t8Nft3uZch7
…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]>
Deploying with
|
| 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 |
|
This PR is stacked on 🤖 sydevs dispatcher |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 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—TranslationSourceleaves two readers outside the mount. - should-fix
lib/i18n/a11y/a11y.ts:50—withA11y'sBaseisaswith extra steps. - should-fix
AGENTS.md:94— retellsa11y.test.ts's cases, and strands the eslint paragraph. - consider
lib/i18n/a11y/catalog.ts:54—RESOLVEDmemos less work than the spread beside it. - Body, no thread: the ⚠ still asks for a retarget once #327 merges; #327 is
5d6cbd9and the base ismain. Andserver/payload-types.tsis not a path here — the consumer copy istypes/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
`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
|
Four critic threads, all adopted. No base merge needed:
Review body: the stale ⚠ is gone, and the consumer copy reads Lean gate green: lint, types, 1749 tests in 170 files. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
sydevs-bot
left a comment
There was a problem hiding this comment.
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
#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
`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
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
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
Summary
aria-label,sr-only, live-region text) move out of SahajCloud intolib/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.<tab>.a11y, sot('media.a11y.play')resolves as before.a11ygroups, 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) andblocks.a11y.next_session(feat(components): count down to a live class and place the directory #321).Change outline
Contract impact
pnpm sync:translationsnow reproduces this PR's snapshot andContract check (English mirror)passes. Nothing here sets aside a SahajCloud copy: the server simply stopped having them.types/payload/payload-types.tsis untouched here. ThecontractSyncPR after SahajCloud#1246 removes itsa11yinterfaces; until then they sit beside the repo'sa11ytype and agree with it.blocks.live_session.a11y_next_session→blocks.a11y.next_session), pushed to its branch.Test results
.claude/skills/pr-prep/check.sh: lint, typecheck, and 1749 tests in 170 files.pnpm build. A probe string fromhy.jsonappears indist/serverand nowhere indist/client, so only the request's locale reaches the browser. Re-checked after/manifest.webmanifestand/oembedbegan importing the server-only catalog.media.progressfromde.jsonand dropping%{platform}fromblocks.share_onturn twoa11y.test.tscases red.Manual verification
/de/and inspect a carousel's previous/next button. Thearia-labelshould be German./fr/and check that the footer menu landmark's name is French.Notes for reviewer
Megosztás: %{platform}, rather than guessing at an inflection.en-AUhas no file and reads English.a11y.test.tsrequires a file for every other locale SahajCloud defines./de/, visible copy falls back to English but thearia-labels stay German.🤖 Generated with Claude Code