Skip to content

feat(i18n): source translations and the language set from SahajCloud - #205

Merged
Ardnived merged 15 commits into
mainfrom
claude/feat-198-cms-translations
Sep 12, 2026
Merged

Ardnived merged 15 commits into
mainfrom
claude/feat-198-cms-translations

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Every UI string now comes from SahajCloud's sy-atlas-translations, one namespace with nested keys, fetched per locale beside clients/me. public/locales/**, i18next-http-backend, pnpm i18n:add and the /locales/* CORS rule are gone.
  • A committed English snapshot (src/config/translations.en.json) boots i18next synchronously, types every t() key, feeds Ladle and the node lane, and is the last-resort fallback — the CMS still refreshes en at runtime, so an English edit ships with no deploy.
  • The picker offers exactly sy-atlas-config.availableLocales, a set SahajCloud will not save until each locale is published. Anything unusable answers ['en'].

Changes

  • src/config/locale.ts — applyLocale, the single writer of the active language. Two callers: AppShell's layout effect and useLocale().setLocale (feat(i18n): take the language set from SahajCloud, not from supportedLanguages #168's one-writer finding). A generation counter makes the last CALL win rather than the last read to settle, and bootLocale resolves what the boot warm-up should fetch. Both were review findings — see Review round 1.
  • src/config/api/fetch.ts — atlasConfigQuery() / translationsQuery(locale) plus warmConfig / warmTranslations, fired from App and PathBoot so the reads overlap clients/me in both routing modes.
  • src/config/api/client.ts — applyRequestContext sets ?locale= only when absent, so the translations read (the one request whose locale is not the active language) wins.
  • src/types/i18next.d.ts — typed t() keys, plus snapshot satisfies WidgetTranslations against the CMS's own generated types, so a group renamed upstream fails pnpm typecheck.
  • src/config/translations.test.ts — replaces the bundle-parity gate: every call-site key resolves, every snapshot key is referenced, and the widget's tab list is pinned across its three statements.
  • scripts/sync-translations.mjs — pnpm sync:translations [--write], production-only, and it refuses a VITE_SAHAJCLOUD_API_KEY whose origin is not production.
  • 33 files of t() renames through Appendix A of feat(translations): rewrite the Sahaj Atlas schema by widget view, seed all ten locales, and gate availableLocales on them SahajCloud#706, and both namespaces collapse to a bare useTranslation().

Review round 1

The adversarial review's five findings, all adopted. Every thread carries the commit.

  • should-fix — the warm-up warmed a key applyLocale may never read (3dcf995). i18n.language is the raw detected tag; AppShell applies pageLocaleOverride ?? defaultLocale ?? i18n.language through preferredLocale. A host passing locale="fr" and a browser reporting en-US both diverged, so the documented locale parameter got the visible flip the warm-up exists to prevent. bootLocale applies the same precedence and base-tags what preferredLocale would narrow.
  • should-fix — two applyLocale calls could land out of order (1e77210). AppShell's effect runs twice by design, so a ?locale=fr page has an en read and a fr read in flight together, and the slower one won. A generation counter closes it, the catch branch included.
  • consider — WIDGET_TRANSLATION_TABS was exported and referenced nowhere, with the same list stated four times (2b60fef). WidgetTranslations now Picks by it; the two copies that cannot import it are pinned by a spec.
  • consider — a docblock claimed every dynamic family was derived, and two were hand-written (5ff4fa9). They are derived now, with a guard against a source-read table silently matching nothing.
  • consider — styles/fonts.ts still named public/locales (7d2e553). The correction is not only a path: that listing was the offered language set, so a new language and its subset necessarily arrived together. The set is the CMS's answer now, and the docblock says what that costs.

docs/rules/i18n-and-state.md carries both should-fix rules, since the subsystem doc said "one writer" and stopped there (677abac).

Review round 2

@Ardnived asked whether each new file earns its place, and for one consistent vocabulary across language, locale and translations.

No new file is unnecessary. Nine were added and each answers one question: config/locale.ts (who may switch the active language), hooks/use-available-locales.ts (what the operator offers), types/atlas-config.ts and types/translations.ts (what the two reads must look like), types/i18next.d.ts (which keys t() accepts), config/translations.en.json (what boots and what a failed read falls back to), scripts/sync-translations.mjs (how that snapshot is produced), and the two specs.

Three things did change:

  • One word per concept (58fe855). The code was the only place using a second word for what the CMS, the host attribute and the query parameter all call a locale — applyLanguage took available locales, resolved a preferred, and handed it to applyBundle(locale, …), while useLanguages() returned availableLocales. Now locale is a BCP-47 tag the widget can render in and names everything that resolves, narrows, stores or fetches one (applyLocale, bootLocale, preferredLocale, useAvailableLocales, currentLocales, and the files config/locale.ts and hooks/use-available-locales.ts); language is a human language as content — an event's spoken language in a filter, a display name, useLocale().languageCode; translations are the strings. The split is stated once, in docs/rules/i18n-and-state.md. Rename only.
  • ?locale=PT-br was silently ignored (9f987de), found by asking the overlapping-responsibilities question. pageLocaleOverride (lib/shape/locale-param.ts) and preferredLocale (config/i18n-options.ts) answer the same question — does this tag resolve against the offered set — and they cannot share code, because lib/shape imports nothing from config/ to avoid a boot-time cycle. The two hand-kept copies had drifted on case: preferredLocale case-folds and its spec asserts PT-br → pt-BR; pageLocaleOverride did not. A miss there is not a fall back to English — it hands the decision to defaultLocale, so a host's locale="fr" would beat a page URL asking for Portuguese, the precise inversion that function exists to prevent. The widget's own links were never affected: publishLocale writes the offered code verbatim. Spec watched fail on three casings first.
  • Two exports nobody imports (10f947d). FALLBACK_LOCALES and localesFrom are module-local now. The two ways to ask for the offered set stay exported.

One question left open, deliberately not guessed at: bootLocale and AppShell's layout effect each state the same source precedence (?locale= → defaultLocale → the detected tag), and round 1 created that second copy while fixing a drift between them. They narrow differently on purpose — only one has the offered set — so the shareable part is the ordered source list alone. Worth folding onto one exported chain, or is two statements the cheaper answer here?

Preview

Both are branch aliases, so they track the latest push. The manual verification below is still owed against them — the language picker and every label changed.

Contract impact

Hosts observe two changes. https://sahajatlas.com is no longer needed in connect-src (nothing connects there any more; script-src and font-src still do), and cloud.sydevelopers.com, already required, now serves the strings too. Round 2 adds the second: ?locale= matching ignores case, so a page URL a host or a person wrote with different casing is now honoured instead of falling through to the snippet's locale. docs/embedding.md and CHANGELOG.md carry both. No origin moved in either round. Upstream: sydevs/SahajCloud#705 and #706, both merged.

Test results

Re-run on 98a81e8, after review round 2:

  • Lean gate: ✓ pnpm lint && pnpm typecheck && pnpm test:run — 1467 tests, 115 files (was 1466 / 115; the new assertion is the ?locale= casing one).
  • Build and pnpm size were last measured on 54724c9: standalone 295.5 KiB, embed 298.0 KiB, loader 2.6 KiB, all under the 308 / 3.5 KiB budgets. Round 2 is a rename plus a toLowerCase(), so no budget change is expected; CI's own run is the check.
  • pnpm ladle:build: ✓ on 54724c9 (161 files, assert:maps clean).

Manual verification

  1. pnpm sync:translations against production with ATLAS_API_KEY, and confirm it reports no drift. ⚠ The snapshot in this PR was NOT fetched from production — a cloud session has no production key (an unauthenticated read 403s). It was converted from the shipped public/locales/en/*.json through Appendix A, which is the same source SahajCloud's own seed was converted from, and checked key-for-key against the SyAtlasTranslations*Strings types from pnpm types:cms. That makes it correct by construction and unverified by observation; the sync run is what closes the gap.
  2. pnpm review:embed in a browser: locale=de renders German; the picker lists exactly availableLocales; locale=it (not enabled) renders English with no error; no request to /locales/*; a compact card fetches only clients/me, the config and the translations.
  3. Watch the network panel on a locale="fr" embed and on an en-US browser (for 3dcf995). Exactly one sy-atlas-translations request should go out per load, and its ?locale= should be the language that ends up rendered. Two requests, or one whose locale is not what renders, means the warm-up and the effect have drifted apart again.
  4. Block the translations read in devtools — the widget must render English, never raw keys, and ERROR_POLICY.fallbackText must still show for a boot failure.
  5. Operator steps from feat(translations): rewrite the Sahaj Atlas schema by widget view, seed all ten locales, and gate availableLocales on them SahajCloud#706 must already be done in production (seed run, ten locales published, availableLocales set). Until they are, the picker shows English only — by design, not a regression.

Notes for reviewer

  • The security-review sweep did not run in this session either. The diff matches securityReview.triggerPattern (src/config/api/, App.tsx, Widget.tsx, package.json, .env, vite.config.ts), so it is still owed. The security-relevant surface is small and worth a direct look: the new reads are two authenticated GETs to the existing API origin, applyRequestContext's has() guard is the only auth/locale change, and sync-translations.mjs is build-time only with a rule that keeps a non-production key away from production. Neither review round added an origin, a sink, or a new input — round 2 is a rename, two unexports, and a toLowerCase() on a value that was already read from the same query string.
  • useLocale now imports config/locale, which imports the i18next singleton. That is new coupling, and it is why CompactEmbedView.mount.test.tsx had to add initReactI18next to its mock.
  • src/lib/brand.test.ts now checks one locale where it checked ten. The other nine live in the CMS and nothing here can read them; English is the source translators work from, which is the direction that still matters.
  • The filters.* / sort.* dynamic families and the messageKey tables cast to TranslationKey — the type system cannot narrow a template literal, and widening t() to string would have lost the check everywhere else.
  • Font subsets are now pinned to a set this repo cannot read (7d2e553). Latin, latin-ext and cyrillic cover today's ten locales. Publishing a locale in a script neither face covers would render in the visitor's system sans with every gate here green. Not a regression this PR introduces so much as one it makes reachable, and worth a follow-up if the offered set is going to grow.
Detail

Why the snapshot is derived rather than fetched. pnpm sync:translations reads production with ATLAS_API_KEY; a routine holds no such key, and GET /api/globals/sy-atlas-config answers 403 unauthenticated. Two things make the derived file trustworthy anyway: SahajCloud#706 §2 states the ten seed files were themselves converted from this repo's public/locales/** through Appendix A, so the values have one common ancestor; and every group was verified against the SyAtlasTranslations*Strings interfaces that pnpm types:cms pulled from main in this session — 31 groups, 194 storage keys, no missing or extra key. The --write run is still the acceptance criterion.

Boot order. warmConfig / warmTranslations fire from App's mount effect ungated by compact (the card is localized too) and from PathBoot, which reads clients/me above App in path mode. Both pass the factory verbatim to prefetchQuery, so React Query merges them into one request per key — which is exactly why both must pass the same locale, and why they now both call bootLocale.

What bootLocale can and cannot do. It cannot run preferredLocale's narrowing, because that takes availableLocales and the config read is the other half of the same warm-up. So it narrows the one way that needs no set: ?locale= verbatim, since the widget writes that parameter itself out of the offered set and an exact match wins step 1; everything else base-tagged, which is step 2. A locale nobody published still misses, as it always did — one speculative prefetch, and applyLocale lands on English regardless.

What the two gates each catch. translations.test.ts catches a key the copy does not answer and copy nothing renders; src/types/i18next.d.ts catches a misspelled key at compile time and a snapshot that has drifted from the CMS. The second direction of the referenced-key check deliberately accepts a key quoted anywhere in source, not only inside t() — a key held in a constant and handed to t elsewhere is reachable copy, and the stricter direction is what catches a typo. Both were watched fail: the run that added them surfaced event.display.register_now (a key the rename missed inside a multi-line ternary, caught by the typed keys) and two stale keys in docblocks.

Reading a table out of source has its own failure mode, which round 1 introduced and guarded in the same commit. A renamed constant makes the regex return [], every assertion downstream then passes for a reason unrelated to the copy, and DYNAMIC_KEYS still clears its own floor on the families that do match. derives each dynamic family from a table it actually found asserts emptiness only — pinning the contents would have put the hand-written list back one file over, which is the finding it was fixing.

Copy budgets moved to the CMS as maxLength + strict (SahajCloud#705), so i18n-budgets.test.ts is deleted rather than ported — a gate here could only ever measure English.

Closes #198
Closes #28
Closes #167

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

The widget's UI copy moves out of `public/locales/**` and into SahajCloud's
`sy-atlas-translations` global, read per locale beside `clients/me`. A committed
English snapshot (`src/config/translations.en.json`, written by
`pnpm sync:translations`) initialises i18next synchronously, types every `t()`
key, feeds Ladle and the specs, and is the last-resort fallback — while the CMS
still refreshes `en` at runtime, so an English edit ships without a deploy.

The languages the picker offers are now `sy-atlas-config.availableLocales`, a set
SahajCloud refuses to save until each locale's translations are published, so a
row in the menu is a row that leads somewhere. Anything unusable answers `['en']`.

`applyLanguage` (`config/language.ts`) is the single writer of the active
language, with exactly two callers: `AppShell`'s layout effect and
`useLocale().setLocale`. `applyRequestContext` now fills `?locale=` only when it
is absent, so the translations read — the one request whose locale is not the
active language — wins.

Every `t()` key is renamed through Appendix A of sydevs/SahajCloud#706, and the
two namespaces collapse to one. `i18next-http-backend`, `pnpm i18n:add`, the
`/locales/*` CORS rule and `VITE_HOST` all go with the bundles.

Closes #28, #167. Supersedes #168. Part of sydevs/SahajCloud#702.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`docs/embedding.md` is what an embedding site reads, so the CSP change lands there
in the same PR: `https://sahajatlas.com` leaves `connect-src` (nothing connects
there any more), `cloud.sydevelopers.com` now serves the strings as well as the
data, and the raw-key troubleshooting row becomes an English-copy one, since a
blocked read now shows English rather than dotted key names.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: 98a81e8
Status: ✅  Deploy successful!
Preview URL: https://6e25bb99.sahajatlas.pages.dev
Branch Preview URL: https://claude-feat-198-cms-translat.sahajatlas.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 12, 2026
@sydevs-bot

sydevs-bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running
CI fix 1

recent dispatches
  • 18:17Z address-review · attempt 1 · session · done
  • 18:17Z address-review · attempt 1 · session
  • 17:12Z address-review · attempt 1 · session · done
  • 17:12Z address-review · attempt 1 · session
  • 17:04Z adversarial-review · attempt 1 · session · done

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

Every job on this PR died at `pnpm install --frozen-lockfile` with
`ERR_PNPM_OUTDATED_LOCKFILE`, including both Cloudflare Pages builds, so
nothing in CI ran against the change at all. The branch removed
`i18next-http-backend` from `package.json` when the locale bundles moved to
the CMS, but left the lockfile's entry for it in place.

`pnpm install` drops that importer entry, the package, and its transitive
`cross-fetch`. Nothing else moves. `pnpm install --frozen-lockfile` now
resolves, and the full gate is green on the result: lint, typecheck, 1455
tests in 114 files, `pnpm build`, and `pnpm size` (standalone 295.4 KiB,
embed 297.9 KiB, loader 2.6 KiB, all under budget).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@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 Sep 12, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🧐 Adversarial review

This tracks #198 closely: the scope and both gates are the ticket's, and most of the 5k diff is regenerated payload-types.ts. The contract work is right — connect-src drops sahajatlas.com, and the CSP table, troubleshooting row and CHANGELOG.md carry it. Two findings sit against the ticket's own boot-order argument.

Findings

  • should-fix — the warm-up warms a locale applyLanguage never reads (App.tsx:204, Widget.tsx:126).
  • should-fix — two applyLanguage calls can land out of order (config/language.ts:27).
  • consider — WIDGET_TRANSLATION_TABS is unreferenced; the tab list exists 4× (types/translations.ts:30).
  • consider — a docblock overclaims: two families are hand-written (config/translations.test.ts:26).
  • consider — styles/fonts.ts:44 still names public/locales; #198 listed the file.

What was checked

#198 and its acceptance list; the whole diff; language.ts, use-languages.ts, i18n-options.ts, client.ts, fetch.ts and docs/embedding.md read whole. No VITE_HOST reader survives.

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


Generated by Claude Code

Comment thread src/App.tsx Resolved
Comment thread src/config/locale.ts Resolved
Comment thread src/types/translations.ts Resolved
Comment thread src/config/translations.test.ts 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 Sep 12, 2026
`applyLanguage` is the one writer of the active language, but nothing ordered
two calls to it. `AppShell`'s layout effect keys on the offered set, which
answers the `['en']` floor until `sy-atlas-config` lands and the real set a
beat later — so a `?locale=fr` page issues `applyLanguage('fr', ['en'])` and
`applyLanguage('fr', [...])` within one frame, resolving to `en` and `fr`
respectively, both awaiting a bundle. Whichever read the network answered last
called `changeLanguage` last. A slow English read left the widget on English
permanently, under a French `<html lang>` — #168's failure reached through one
function instead of three.

A module-level generation counter, claimed before the first await and checked
before `applyBundle`, makes the ordering call order rather than settle order.
The catch branch is guarded too: a superseded request still reports its failure
but must not drag the widget back to English, because a newer call is already
deciding.

`src/config/language.test.ts` is new — the module had no spec. Both ordering
assertions were watched fail with the guards removed (`['fr', 'en']` instead of
`['fr']`) before being restored.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`warmTranslations(i18n.language)` warmed a query key `applyLanguage` may never
read. `i18n.language` is the raw detected tag (`querystring → hostHtmlLang →
navigator`); `AppShell` applies `pageLocaleOverride(search) ?? defaultLocale ??
i18n.language` through `preferredLanguage`. They diverge in two ordinary cases:

- a host passing `locale="fr"`, which reaches the widget as `defaultLocale` and
  sits in no detector, so the browser's tag was warmed while French was
  fetched — the documented `locale` parameter got the visible flip the warm-up
  exists to prevent;
- a browser reporting `en-US`, which `preferredLanguage` narrows to `en`, so
  most loads paid for a request nothing read.

`bootLanguage` applies the same precedence, and narrows the one way that needs
no `availableLocales` — the set has not arrived yet, being the other half of
this same warm-up. `?locale=` is warmed verbatim, since the widget writes that
parameter itself out of the offered set and an exact match wins step 1. The
attribute and the browser tag are base-tagged, which is step 2. Both `App` and
`PathBoot` call it, so the two warm-ups still merge on one key.

Five new assertions in `src/config/language.test.ts`, each watched fail against
the old `i18n.language` before the fix went in. The last one states the
property directly: the key warmed equals what `preferredLanguage` resolves.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`WIDGET_TRANSLATION_TABS` was exported and referenced nowhere, while the same
list was stated four times: that constant, `TRANSLATION_SELECT` in
`config/api/fetch.ts`, the `Pick<>` in `WidgetTranslations`, and the check in
`scripts/sync-translations.mjs`. Adding a tab meant editing three of the four,
and nothing failed if you missed one — the sync script fetches everything and
strips, so a group the CMS added reached the snapshot without ever being
requested at runtime.

`WidgetTranslations` now `Pick`s by the constant, which removes one copy and
makes the constant load-bearing. The other two cannot import it: the SDK
type-checks `TRANSLATION_SELECT` against the generated CMS types, which needs
its `true` literals, and the sync script is a node `.mjs` with no compiler. So
a spec holds all three together instead. The script's list moves into a named
`WIDGET_TABS` const so the spec has a stable anchor.

Watched fail: adding `'emails'` to the constant alone turns the new spec red.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The docblock promised "each family below is derived from the constant that
generates it, never from a hand-written list", and two of the four were not.
`FILTER_OPTIONS` and `SORT_ORDERS` spelled their options out here, so adding a
filter format or a sort order did need an edit in this file — the opposite of
what the reader is told, and exactly the stale copy the second direction of
this gate exists to catch elsewhere.

`TIME_PERIODS` and `SORT_ORDERS` are already exported from `lib/shape`, so
those import. `FORMAT_OPTIONS` and `CADENCE_OPTIONS` are module-local to the
component that renders them, so a new `arrayLiterals` reads them out of its
source the way `WEEK_NUMBERS` reads `use-event-display.ts`. Only each group's
fixed chrome — its `label`, and the `any` that clears it — stays written down,
because neither is an option in any of those tables.

Reading a table out of source has its own failure: a renamed constant returns
`[]` and every assertion downstream passes for a reason unrelated to the copy,
with `DYNAMIC_KEYS` still clearing its floor on the families that do match. So
a spec asserts each regex-read family found something. It asserts emptiness
only — pinning the contents would put the hand-written list back one file over.

Watched fail twice: renaming `FORMAT_OPTIONS` reds the new guard by name, and
adding a real third format reds the resolve check with no test edit, which is
what proves the derivation is live.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`fonts.ts` still said the shipped subsets were "limited to what `public/locales`
needs", a directory #198 deleted. #198 listed the file and the rename was
missed.

The correction is not only a path. That listing WAS the offered language set,
so a new language and its subset necessarily arrived in one commit. The set now
comes from `sy-atlas-config.availableLocales` at runtime, which means an
operator publishing a locale in a script neither face covers gets the system
sans, with every gate here green. The docblock says so.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Both findings this PR just fixed were reachable because the subsystem rule said
"one writer" and stopped there. It now says what the counter in `language.ts`
is for, and that the boot warm-up goes through `bootLanguage` rather than
`i18n.language`, so the next reader does not re-derive either.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`<T,>` is the .tsx disambiguator, and this file is .ts, where it is just a
trailing comma. `--max-warnings 0` makes it a CI failure.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

All five review findings adopted on 54724c9. None rebutted, none needing a decision. Every thread has a reply and is resolved.

Gates green locally: lint, typecheck, 1466 tests in 115 files, build, pnpm size (295.5 / 298.0 / 2.6 KiB), ladle:build. The security sweep is still owed; round 1 added no origin or sink.

🤖 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 Sep 12, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review September 12, 2026 17:32
@sydevs-bot
sydevs-bot requested a review from Ardnived September 12, 2026 17:32
@Ardnived

Copy link
Copy Markdown
Contributor

@sydevs-bot Look over all the newly introduced files and challenge whether each of them are necessary and what role they provide. Look for:

  • Overlapping responsibilities
  • Excessive abstraction
  • Confusing terminology between: language, locale, and translations - we want consistent and clear terminology
  • Code bloat

Create a review on this PR which will then be picked up by the address-review dispatcher

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Sep 12, 2026
The reviewer asked for consistent terminology across the files #198 adds.
Three words named two things, mixed inside single expressions: `applyLanguage`
took `available` locales, resolved a `preferred`, and handed it to
`applyBundle(locale, …)`; `useLanguages()` returned `availableLocales`; a
`languages` variable fed `pageLocaleOverride`. Every input and output on this
path is spelled `locale` by the CMS, the host attribute and the query
parameter, so the code was the only place using a second word for it.

The split is now stated once, in `docs/rules/i18n-and-state.md`:

- LOCALE — a BCP-47 tag the widget can render in. Everything that resolves,
  narrows, stores or fetches one is named for it: `applyLocale`, `bootLocale`,
  `preferredLocale`, `useAvailableLocales`, `currentLocales`, `localesFrom`,
  `FALLBACK_LOCALES`, and the files `config/locale.ts` and
  `hooks/use-available-locales.ts`.
- LANGUAGE — a human language as content: an event's spoken language in a
  filter, a display name for one, and `useLocale().languageCode`, the base
  subtag a font subset keys on. `languageLabel` and `nativeLanguageLabel` keep
  their names because they are about that axis, not this one.
- TRANSLATIONS — the strings: one bundle per locale.

Rename only. No call site changes behaviour, and the docs naming these symbols
move with them.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`FALLBACK_LOCALES` and `localesFrom` were exported and referenced only inside
this file — grepped across `src`, `scripts`, `tests` and `.ladle`. An export is
a claim that a second caller exists, and a reader who goes looking for one
spends the trip finding out there is none.

There are exactly two ways to ask for the offered set, and both stay exported:
`useAvailableLocales` for a render, `currentLocales` for an event handler.
`localesFrom` is what keeps those two from answering differently, which is a
reason to keep the function, not to publish it.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`pageLocaleOverride` and `preferredLocale` answer the same question — does this
tag resolve against the offered set — and they cannot share code: `lib/shape`
imports nothing from `config/`, because `config/i18n-options.ts` already imports
`LOCALE_PARAM` from there and the cycle would surface as a boot-time TDZ error
that typecheck cannot see.

Two hand-kept copies of one rule had drifted on exactly one input. `?locale=PT-br`
resolves to `pt-BR` in `preferredLocale`, whose spec asserts it, and missed here.
A miss is not "fall back to English": it hands the decision to `defaultLocale`,
so a host's `locale="fr"` would have beaten a page URL asking for Portuguese —
the precise inversion this function exists to prevent.

The widget's own links are unaffected: `publishLocale` writes the offered code
verbatim. This is about a link a host or a person wrote.

Spec watched fail on all three casings before the fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The host contract changes with the fix one commit back: a page URL whose locale
tag is cased differently from the offered code is now honoured where it used to
fall through to the snippet's own `locale` parameter. `docs/embedding.md` and
`CHANGELOG.md` are the only documentation an embedding site reads, so both carry
it.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Terminology unified, one divergence fixed, one question back to you.

⚠ I cannot open a review — that channel is adversarial-review's. Comment @sydevs-bot review to fire it.

Adopted

  • One word per concept (58fe855). Locale is a tag we render in: applyLocale, bootLocale, preferredLocale, useAvailableLocales, config/locale.ts. Language is content — an event's, a display name. Translations are the strings. Rule in docs/rules/i18n-and-state.md.
  • ?locale=PT-br was ignored (9f987de). pageLocaleOverride and preferredLocale answer one question in two files and had drifted on case. A miss is not English — it hands the pick to defaultLocale, so a host's locale="fr" beat a page URL asking for Portuguese. Docs carry it (98a81e8).
  • Two exports nobody imports (10f947d).

Asked

No new file is unnecessary. But bootLocale and AppShell each state the same source precedence — round 1 made that copy. Fold onto one chain, or leave two?

Gate green.

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


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 12, 2026
@Ardnived
Ardnived merged commit b78bf6f into main Sep 12, 2026
13 checks passed
@Ardnived
Ardnived deleted the claude/feat-198-cms-translations branch September 12, 2026 18:57
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

3 participants