Repository navigation
Description
Blocked by sydevs/SahajCloud#705 and sydevs/SahajCloud#706. Do not start until both are merged to main and production is seeded and published — pnpm types:cms reads from main, so running it earlier silently pulls the old shape.
Closes #28 and #167. Supersedes PR #168 (its measured boot order, preferredLanguage, the one-writer finding and the sync-script production-key rule are reused; its shipped ∩ enabled split is moot once nothing is shipped). Part of sydevs/SahajCloud#702.
Summary
- Every UI string comes from
sy-atlas-translations, one i18next namespace with nested keys (event.display.chip_full), fetched per locale in parallel withclients/me.public/locales/**,i18next-http-backend,pnpm i18n:addand the/locales/*CORS rule go. - A committed English snapshot (
src/config/translations.en.json, written bypnpm sync:translations, never hand-edited) initialises i18next synchronously, types everyt()key, feeds tests and Ladle, and is the last-resort fallback. The CMS still refreshesenat runtime, so an English edit ships without a deploy. - The languages the widget offers are
sy-atlas-config.availableLocales— an operator's set, each locale published in the CMS. The picker lists exactly that set; alocalenaming anything else is corrected to English. - Hosts observe one change:
connect-src https://sahajatlas.comis no longer needed (nothing connects to it —script-src/font-srcstill do), andcloud.sydevelopers.com, already required, now also serves the strings.
Background
src/config/i18n.ts loads ${VITE_HOST}/locales/<lng>/<ns>.json over HTTP; supportedLanguages in i18n-options.ts is pinned to the directory listing; nine files read public/locales from disk; ERROR_POLICY carries English fallbackText because a bundle may never arrive. #28 asked for the CMS to own the strings, #167 for it to own the set, and PR #168 built the set half against the old languages field. SahajCloud has since (child 1 + child 2) rewritten the global by widget view, seeded ten locales, added per-locale publish status, availableLocales with a "published or refuse" validator, and a client-read English merge — so a non-English read is already complete and fallbackLng only matters when the read fails. The key contract is sydevs/SahajCloud#706 Appendix A; this issue renames every call site through it.
Proposed changes
1. Two reads, warmed with clients/me
src/config/api/fetch.ts + index.ts:
atlasConfigQuery()—['atlas-config'],sdk.findGlobal({ slug: 'sy-atlas-config', depth: 0, select: { availableLocales: true } }), zodAtlasConfigSchema(availableLocales: string[] | nullish),staleTime: ATLAS_CONFIG_STALE_TIME(=REGIONS_STALE_TIME),gcTime: WHOLESALE_GC_TIME,retryOnMount: false. Locale-agnostic; the interceptor's?locale=is harmless.translationsQuery(locale)—['translations', locale],sdk.findGlobal({ slug: 'sy-atlas-translations', locale, depth: 0, select: <every widget tab; never emails or event.title> }), parsed through a lightTranslationBundleSchema, same windows.applyRequestContext(src/config/api/client.tsline 34) setslocaleonly when absent, so the SDK's explicit?locale=for the translations read wins; every other request keeps the resolved language.fetch.test.tsgains the pin.api.warmConfig()andapi.warmTranslations(i18n.language)fire fromApp's mount effect (ungated bycompact— the card is localized) and fromPathBootinWidget.tsx, which readsclients/meaboveApp(feat(i18n): take the language set from SahajCloud, not fromsupportedLanguages#168 measured: warmed in parallel the config settled 1 ms afterclients/me; serialized, the language flipped in front of the viewer). Both pass the factory verbatim toprefetchQuery.
2. i18next: snapshot at init, CMS bundles on demand, one writer
src/config/i18n.ts: no backend;resources: { en: { translation: snapshot } };initImmediate: false(init is synchronous, so nothing suspends on i18n any more — remove theuseSuspense: falseoptions and the "cold boot can suspend" comments inWidget.tsx,views/shared.tsx,views/fallbacks.tsx);react: { bindI18nStore: 'added' }; detector unchanged (querystring→hostHtmlLang→navigator,caches: [],cimodeguard).src/config/i18n-options.ts:defaultNS: 'translation',ns: ['translation'],%{}interpolation kept,supportedLngsandsupportedLanguagesremoved. Plurals:event.display.sessions_countwithcountresolves_one/_few/_many/_othernatively.- New
src/config/language.ts—applyLanguage(requested):preferred = preferredLanguage(requested, availableLocales)(feat(i18n): take the language set from SahajCloud, not fromsupportedLanguages#168's helper: case-fold → base tag → regional variant →en); if the bundle is cached,addResourceBundle(preferred, 'translation', bundle, true, true)+changeLanguage(preferred)synchronously; elseensureQueryData(translationsQuery(preferred))then the same; on failurechangeLanguage('en')+reportInternalError. Exactly two callers:AppShell's language effect (auseLayoutEffectreplacingApp.tsxlines 320-323;defaultLocaleconsumed once via a ref;pageLocaleOverride(search, availableLocales)keeps its precedence) anduseLocale().setLocale.enis applied through the same path, so a CMS edit to English lands at runtime. - Accepted: if a
?locale=frpage's bundle lands afterclients/me, one English frame paints first (the case feat(i18n): take the language set from SahajCloud, not fromsupportedLanguages#168 measured as overlapped in both routing modes); locale-keyed caches then refetch once.
3. The language set
- New
src/hooks/use-languages.ts→availableLocales, or['en']when the read fails, is empty, or lacks the field (never offer a language whose publication cannot be proven; a CMS that cannot answer this cannot answerclients/meeither). SettingsMenu.tsxline 122: rows fromuseLanguages(), CMS order,nativeLanguageLabelendonyms. Standalone<html lang>/dirvia Helmet and the widget root'slang/dirunchanged (i18n.dir('fa')isrtl).hostHtmlLangDetectorunchanged. ThesupportedLngsnarrowing caveat from feat(i18n): take the language set from SahajCloud, not fromsupportedLanguages#168 disappears with the option.
4. Snapshot, sync script, gates, typing
scripts/sync-translations.mjs(pnpm sync:translations [--write]), modelled onscripts/sync-atlas-contract.mjsand feat(i18n): take the language set from SahajCloud, not fromsupportedLanguages#168'ssync-atlas-languages.mjs: reads production only; key fromATLAS_API_KEY(shell or.env.localvia Vite'sloadEnv), falling back toVITE_SAHAJCLOUD_API_KEYonly whenVITE_SAHAJCLOUD_URLis the production origin — a local key must never reach production's logs; strips metadata,emails,event.title; sorts keys; refuses a missing tab or any blank value; exit 1 on drift without--write. Writessrc/config/translations.en.json.src/config/translations.test.tsreplaces the parity gate: every literalt()key insrc/**resolves in the snapshot; the dynamic families resolve from their constants (filters.format/cadence/timeoptions, sort orders,REGISTRATION_QUESTION_NAMES,WEEK_NUMBER_KEYS,ERROR_POLICY[*].messageKey, bothREFUSAL_MESSAGE_KEYS,STATE_MESSAGE_KEYS);sessions_count_one/_otherpresent; no blank value; and every snapshot key is referenced (no dead copy in the CMS).src/types/i18next.d.ts:CustomTypeOptions.resources = { translation: typeof snapshot }(typedt());TranslationKeyderived fromRequired<Pick<SyAtlasTranslation, …widget tabs>>afterpnpm types:cms, withsnapshot satisfies WidgetTranslationsso the snapshot cannot drift from the CMS types.FallbackPolicy.messageKeyandStripTranslatetakeTranslationKey.
5. Call sites, deletions, tests, docs
-
Rename every
t()key 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 (33 files, listed under Files affected); collapse everyuseTranslation('common'|'events')andtEvents/tCommonpair touseTranslation();ERROR_POLICY.messageKeyrenamed,fallbackTextstays hardcoded (tracker decision 6). -
Delete
public/locales/**,scripts/add-locale-key.mjs+i18n:add,i18next-http-backend, the/locales/*rule inpublic/_headers,src/config/i18n-budgets.test.ts,VITE_HOST(its only reader wasloadPath:.env,vite.config.tsCF_PAGES_URLfallback,serve-embed-review.mjsport derivation, docs). -
Disk-reading tests:
i18n-options.test.ts(drop bundle parity,UNTRANSLATED_EVENT_KEYS,supportedLngsround-trip; addpreferredLanguagecases);i18n-budgets.test.ts(deleted — budgets aremaxLength+strictin the CMS);src/types/event.test.tslines 191-211 (deleted — CMS-side spec + the dynamic-family gate);src/lib/brand.test.ts,Fallbacks.test.tsx,CompactEmbedView.test.tsx,.ladle/i18n.ts(read the snapshot);src/styles/fonts.ts+ test (subsets named against the CMS locale set: latin, latin-ext, cyrillic cover the ten;el/hy/fa/bgwould need a subset and degrade to the system sans until added). The 18 component tests that mockreact-i18nextto echo keys get renamed expectations. -
Smoke:
boot-origins.smoke.test.tsdrops thelocale JSON (VITE_HOST)pattern and the three/locales/*tests, keeps theVITE_SAHAJCLOUD_URLprivate-origin check;robots.smoke.test.tspins CORS-plus-noindex on/embed.jsinstead. -
Size:
enbundles are 3.3 KiB gzipped; bundled ≈ +3.5 KiB, minus ≈ 2 KiB for the backend; net ≈ +1.5 KiB againstBUDGET_KIB = 308on a ~300–303 KiB embed. Budget holds. If a build lands within 2.1 KiB of 308, raise to 310 in the same commit with the measurement. -
Docs:
docs/embedding.md—localerow (an unenabled language falls back to English; the set is SahajCloud's), "follows your page's language" section, CSP block (drophttps://sahajatlas.comfromconnect-src; delete the "keep it regardless — the locale JSON" note and table row; saycloud.sydevelopers.comalso serves the strings), "Where to load it from" (delete the compiled-in locale host and curl recipe), troubleshooting row "Every label reads likeevents.title" → "labels are English on a non-English page:connect-src cloud.sydevelopers.commissing, or the language is not enabled in SahajCloud".CHANGELOG.mdUnreleased/Changed entry.AGENTS.md(i18n row, file layout, conventions bullet,_headersbullet,VITE_HOSTbullet, Accent-history paragraph).docs/rules/i18n-and-state.md(+.claude/rulessymlink): i18next section rewritten around the snapshot, the single writer,count, and this workflow note from refactor(i18n): source translations from SahajCloud CMS #28:Translations are CMS-owned. All Sahaj Atlas UI copy lives in SahajCloud's
sy-atlas-translationsglobal — do not hand-edit strings in this app;src/config/translations.en.jsonis generated. To add, rename or remove a key, open an issue onsydevs/SahajCloud— search the open ones first and update the outstanding request rather than duplicating it. Once the CMS ships the key, runpnpm sync:translations --writeand wire thet()here.Also
docs/environment.md(VITE_HOST→ATLAS_API_KEY),docs/testing.mdboot-origins story,docs/rules/mapbox.mdport note,STORYBOOK.md.
Acceptance criteria
-
pnpm types:cmsrun after both SahajCloud children are onmain;SyAtlasTranslation/SyAtlasConfigshow the new shape (availableLocales,common.chrome, …). - No
public/locales,i18next-http-backend,VITE_HOST, or/locales/*reference remains in source, config,_headers, tests or docs. -
src/config/translations.en.jsonexists, is produced bypnpm sync:translations --write, andpnpm sync:translationsreports no drift. - Every
t()call site uses a key from Appendix A;pnpm typecheckrejects a misspelled key;translations.test.tspasses in both directions. -
pnpm review:embedin a browser:locale=derenders German from the CMS; the picker lists exactlyavailableLocales;locale=it(not enabled) renders English with no error; no request to/locales/*; a compact card fetches onlyclients/me, the config and the translations; the standalone<html lang>/dirfollow the active locale. - With the translations read failing (blocked in devtools), the widget renders English, never raw keys, and
ERROR_POLICY.fallbackTextstill shows for a boot failure. - Copy budgets are no longer asserted here;
i18n-budgets.test.tsand theevent.test.tsquestions check are gone with a pointer to the CMS specs. -
pnpm sizepasses; the measured embed and any budget change are recorded in the PR. -
docs/embedding.md,CHANGELOG.md,AGENTS.md,docs/rules/i18n-and-state.mdupdated as above.
Files affected
src/config/i18n.ts,src/config/i18n-options.ts(+test), newsrc/config/language.ts,src/config/translations.en.json,src/config/translations.test.ts,src/config/query-client.tssrc/config/api/client.ts,fetch.ts,index.ts(+fetch.test.ts); newsrc/types/atlas-config.ts,src/types/translations.ts,src/types/i18next.d.ts;src/types/index.tssrc/App.tsx,src/Widget.tsx,src/hooks/use-locale.ts, newsrc/hooks/use-languages.tst()call sites:src/hooks/use-event-display.ts;src/views/{CountriesView,SearchView,FilterView,RegionView,OnlineView,EventView,CalendarView,RegistrationView,ShareView,CompactEmbedView,DrawerStack (+strip-label.ts),FullInterface,fallbacks,shared}.tsx;src/components/atoms/Dropdown;src/components/molecules/{ActiveFilterPills,AddToCalendar,EventActions,EventChips,EventListItem,EventMetadata,Fallbacks,GeolocationPrompt,ImageCarousel,SearchFilters,SettingsMenu (+story),ShareContent (+platform-buttons),SortMenu};src/components/organisms/{EventDetails/EventDetails,EventDetails/EventRegister,EventsList/LoadMore,Mapbox/Map,Mapbox/MapSearch,RegistrationForm,ReportIssueForm/ReportIssueForm,ReportIssueForm/ReportIssueModal}; the 18 component tests that echo keys- Tests:
src/config/i18n-budgets.test.ts(delete),src/types/event.test.ts,src/lib/brand.test.ts,src/components/molecules/Fallbacks/Fallbacks.test.tsx,src/views/CompactEmbedView/CompactEmbedView.test.tsx,src/styles/fonts.ts+fonts.test.ts,tests/smoke/boot-origins.smoke.test.ts,tests/smoke/robots.smoke.test.ts .ladle/i18n.ts;scripts/sync-translations.mjs(new),scripts/add-locale-key.mjs(delete),scripts/serve-embed-review.mjs;public/locales/**(delete),public/_headers;package.json,pnpm-lock.yaml,.env,vite.config.ts- Docs:
docs/embedding.md,CHANGELOG.md,AGENTS.md,docs/rules/i18n-and-state.md,docs/environment.md,docs/testing.md,docs/rules/mapbox.md,STORYBOOK.md
Verification checklist
-
pnpm lint && pnpm typecheck && pnpm test:run && pnpm build && pnpm size && pnpm ladle:build -
pnpm sync:translations(no drift) andpnpm sync:translations --writeagainst production withATLAS_API_KEY; confirm the script refuses a localVITE_SAHAJCLOUD_API_KEY. - Every new assertion reintroduced-as-a-defect and watched fail (
docs/testing.md): the referenced-key gate both ways, the explicit-locale interceptor pin,preferredLanguage, the['en']fallback. - Browser (
pnpm review:embed+ Playwright):locale=de,locale=de-DE,locale=it,?locale=fron the page, picker switch, path routing (data-sahaj-atlas-readyreports{"routing":"path"}), compact card request list, standalone<html lang>. - Security review (trigger:
src/config/api/,App.tsx,Widget.tsx,package.json,.env,vite.config.ts). - Smoke lane green against the Cloudflare preview with the trimmed
boot-originsandrobotsspecs.
References
- Contract: feat(translations): rewrite the Sahaj Atlas schema by widget view, seed all ten locales, and gate availableLocales on them SahajCloud#706 Appendix A (old → new keys), B (consolidations), C (dropped). Infra: feat(translations): typed JSON groups, per-locale publish status, and an availableLocales field gated on published translations SahajCloud#705. Tracker: feat(translations): CMS-sourced UI strings + availableLocales for Sahaj Atlas and WeMeditate Web (tracker) SahajCloud#702.
- Closes refactor(i18n): source translations from SahajCloud CMS #28 (its key table is superseded by Appendix A; its
toSahajLocale/pt-britem is obsolete — the CMS uses BCP-47pt-BR), feat(i18n): take the language set from SahajCloud, not fromsupportedLanguages#167. Supersedes PR feat(i18n): take the language set from SahajCloud, not fromsupportedLanguages#168 (boot-order measurements,preferredLanguage, one-writer finding, sync-script design and its production-key rule). - Earlier host-visible entries: feat(widget): implement routing=path #165 (page language), feat(feedback): land a post-event reader in the atlas, not a dead-end card #181, fix(i18n): production hygiene for logging, locales, storage and third-party flows #120. Boot-origins story:
docs/testing.md. - Follow-up: globals bypass SahajCloud's usage and cache plugins (tracker stub).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Projects
- StatusShow more project fieldsDone
Activity
sydevs-bot commentedon Sep 12, 2026
@Ardnived unblocked: every blocker is closed. Say
@sydevs-bot implementto start.🤖 sydevs dispatcher
Ardnived commentedon Sep 12, 2026
@sydevs-bot implement
sydevs-bot commentedon Sep 12, 2026
🤖 no session running
recent dispatches
Written by the sydevs dispatcher. Sessions never edit this comment.
docs(fonts): the subset set is the CMS's answer now
fix(translations): the atlas preview landed on a save-first overlay
fix(i18n): one word per concept — locale, language, translations
feat(i18n): source translations and the language set from SahajCloud (#…
feat(fields): declarative live-preview targets, repointed by the open…
docs(claude): move task-only guidance out of the always-loaded root g…
docs(claude): move task-only guidance out of the always-loaded root g…