Repository navigation
Description
Summary
Replace the app's static, file-based i18next translations
(public/locales/<lng>/{common,events}.json loaded via i18next-http-backend)
with translations fetched from the SahajCloud CMS sy-atlas-translations global
(GET /api/globals/sy-atlas-translations?locale=<locale>). The CMS becomes the
single source of truth for all Atlas UI copy — translators manage strings in the
CMS admin instead of editing JSON in this repo.
Depends on the CMS schema landing first: sydevs/SahajCloud#527 (define
Sahaj Atlas translation schema by view).
Background
- Current setup:
i18next+react-i18next;src/config/i18n.tsuses
i18next-http-backendto loadpublic/locales/<lng>/<ns>.json; two namespaces
(common,events); Ruby-style%{var}interpolation (custom delimiter in
src/config/i18n-options.ts);_one/_otherplurals; locale via?locale=+
browser detection. - The app already talks to the CMS:
src/config/api/client.tssends
VITE_SAHAJCLOUD_URL, an API key, andtoSahajLocale(lng)— reuse this. - The CMS global reorganizes strings into five view tabs that will match the
app's planned view split: Common, Region, Event, Registration, Share. Each
top-level tab maps to one i18next namespace.
Proposed changes
1. Replace the i18next backend with a CMS-backed resource loader
Swap i18next-http-backend for a custom backend (or a getResources/addResourceBundle
loader) that calls GET /api/globals/sy-atlas-translations?locale=<toSahajLocale(lng)>
and registers each top-level tab as an i18next namespace. Wire it in
src/config/i18n.ts and src/config/i18n-options.ts (and .ladle/i18n.ts for
stories — stories can use a static English fixture). The CMS response nests
subgroups exactly as i18next expects ({ event: { details: {…} } }), so mapping
is mostly 1:1.
2. Adopt five namespaces and remap t() call sites
Move from 2 namespaces (common, events) to 5 (common, region, event,
registration, share). Update every t() call site. Mapping:
Old (namespace:key) |
New (namespace:key) |
|---|---|
common:* (7 root keys) |
common:* (unchanged) |
common:locations.*, common:venues.* |
region:locations.*, region:venues.* |
events:details.<k> (minus share) |
event:details.<k> |
events:details.share |
share:action |
events:recurrence.<k> |
event:recurrence.<k> |
events:recurrence.null |
event:recurrence.no_recurrence |
events:timing.converted_to |
event:timing.converted_to |
events:registration.<k> |
registration:form.<k> |
events:errors.<k> |
registration:errors.<k> |
events:questions.<k> |
registration:questions.<k> |
events:questions.healthInfo |
registration:questions.health_info |
events:questions.priorExperience |
registration:questions.prior_experience |
events:questions.referralSource |
registration:questions.referral_source |
Known call sites: src/components/molecules/Navbar/LanguageSelector.tsx,
src/components/molecules/EventTime/EventTime.tsx,
src/components/organisms/RegistrationForm/RegistrationForm.tsx,
src/components/organisms/EventView/details.tsx (recurrence + details) — grep
useTranslation( / t( for the full list.
3. Keep interpolation & plurals
%{var} interpolation and _one/_other plural resolution stay unchanged — CMS
values are plain strings that preserve %{var} and the _one/_other keys.
Update the recurrence-key derivation in EventView/details.tsx to emit
no_recurrence for the no-schedule case (was null).
4. Fallback, caching, and offline
- The CMS already falls back to English server-side, so a locale with gaps returns
English strings automatically. - Fetch on init and on
changeLanguage. Add caching (e.g.localStorage/react-query)
and decide whether to bundle a build-time English snapshot as a first-paint/offline
safety net (recommended, given the app can render before the CMS responds).
5. Remove the file-based scheme
- Delete
public/locales/*(or keep only the English fallback snapshot) and drop
thei18next-http-backenddependency frompackage.json. - The global is publicly readable and CORS is open; reuse the existing axios client
(API key +toSahajLocale) for consistency and origin-allowlist coverage.
6. Document the CMS-owned translation workflow (+ a translations label)
Once the CMS owns the schema, strings can no longer be added/edited in this repo.
Add a "Translations" section to the app docs (CLAUDE.md, cross-linked from
README.md) capturing the process, so both humans and AI agents follow it:
Translations are CMS-owned. All Sahaj Atlas UI copy lives in the SahajCloud
sy-atlas-translationsglobal — do not hand-edit strings in this app.To add, rename, or remove a translation key, open an issue on
sydevs/SahajCloudrequesting the
schema change, labelledtranslations.Before opening a new request, search the open
translations-labelled issues
on SahajCloud and update the existing outstanding request instead of creating
a duplicate — batch pending key changes into one request.Once the CMS ships the key, wire up the
t()call here.
The translations label now exists on both repos so these requests are easy to
find and triage.
7. Standardize on BCP-47 locale codes
Represent locales as canonical BCP-47 language tags everywhere the app owns
the value — the ?locale= URL param, i18next lng / resolvedLanguage,
LanguageDetector, changeLanguage(), <html lang> + dir (RTL for fa), and
Intl.DisplayNames (src/hooks/use-locale.ts). Canonical form = lowercase
language subtag + uppercase region subtag (e.g. pt-BR, not pt-br).
The CMS locale codes are not canonical BCP-47 (it uses pt-br), so keep
toSahajLocale() (src/config/api/client.ts) as the single boundary that maps a
BCP-47 tag → the CMS locale set before every CMS request. Verify it lowercases
the region subtag and resolves fallbacks (pt-BR → pt-br, unknown → en).
Coverage mismatch to resolve: the app currently ships hu and nl locale
folders that the CMS does not support (its 16 locales are en, es, de, it, fr, ru,
ro, cs, uk, el, hy, pl, pt-br, fa, bg, tr). Post-migration those resolve to en
via toSahajLocale(). Decide per locale — request the CMS add it (a
translations issue on SahajCloud, per change 6) or accept the English fallback.
Acceptance criteria
- App docs (
CLAUDE.md, linked fromREADME.md) document the CMS-owned
translation-change workflow: request key changes via atranslations-labelled
issue onsydevs/SahajCloud, updating the outstanding request before opening a new one. - The
translationslabel is used on the relevant issues in both repos. - All UI strings render from the CMS in
enand at least one non-English locale
(e.g.fr,ru) with no visible missing keys. -
%{var}interpolation and_one/_otherpluralization still work. - Switching language (selector /
?locale=) refetches and re-renders. - A locale with missing strings falls back to English (no raw keys shown).
- No runtime references to
public/localesremain (except an optional English
fallback snapshot);i18next-http-backendremoved frompackage.json. - Recurrence rendering handles the
no_recurrencecase. - Locale codes are canonical BCP-47 in the app (URL param, i18n config,
<html lang>/dir,Intl.DisplayNames);toSahajLocale()is the only
place BCP-47 → CMS codes are normalized. - The
hu/nlcoverage gap is resolved (CMS locale requested, or English
fallback documented as intentional). - Lint, tests, and the smoke suite pass; app builds.
Files affected
src/config/i18n.ts,src/config/i18n-options.ts,.ladle/i18n.ts— backend swap- BCP-47 language tags.
- (new) CMS-backed i18next backend/loader module.
src/config/api/client.ts— reuse the CMS client; confirmtoSahajLocale()is the
BCP-47 → CMS-code boundary.src/hooks/use-locale.ts— BCP-47 tags intoIntl.DisplayNames.- All
t()call sites (LanguageSelector, EventTime, RegistrationForm,
EventView/details, …). package.json— dropi18next-http-backend.public/locales/*— removed or trimmed to an English fallback.CLAUDE.md(+README.mdlink) — new "Translations" workflow section.
References
- Depends on: feat(translations): define Sahaj Atlas translation schema by view SahajCloud#527 — define Sahaj Atlas translation schema by view.
- CMS endpoint:
GET /api/globals/sy-atlas-translations?locale=<code>(public read,
English fallback, 16 locales). - Locale mapping:
toSahajLocale()insrc/config/api/client.ts. - BCP-47 language tags: https://www.rfc-editor.org/info/bcp47.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Projects
- StatusShow more project fieldsDone
Activity
Ardnived commentedon Sep 5, 2026
Superseded by #198 and the tracker sydevs/SahajCloud#702. The key-mapping table here is replaced by Appendix A of sydevs/SahajCloud#706 (the schema is rewritten by widget view, not the 5-tab shape this described); the
toSahajLocale/pt-britem is obsolete now that the CMS uses BCP-47.feat(i18n): source translations and the language set from SahajCloud (#…