Skip to content

I18N-P0 / I18N-P1 — English framework and French switcher (design)

Version: 1.6
Last Updated: 2026-08-04 18:12:44
Status: I18N-P0 extraction complete; I18N-P1 switcher + Intl helpers + locale smoke pack in place Spec: 03-REQUIREMENTS-INTERNATIONAL-LANGUAGE.md (normative; REQ-IDs authoritative) Roadmap: 04-ROADMAP §15 · Phase 3 Architecture: 01-ARCHITECTURE.md — Internationalisation architecture

This document is the design for the first two phases of the international language programme. It does not restate doc 03; it records the engineering decisions, the measured scope, and the deviations from doc 03 that were agreed on 2026-08-03. The implementation plan is a separate artefact.


Doc 03 is complete as a product specification (REQ-I18N-01…38, build order locked). The §4.1 foundation is implemented and §3.3 extraction batches 1–20 are complete (react-i18next + t() across pages/components; ESLint i18n ratchet holds two intentional permanent exempts). I18N-P1 engineering (locale persistence, switcher, Intl helpers) is in progress. Wave 1b locale plug-ins (I18N-P2a/P2b), marketing language (I18N-M1), backend template localisation (I18N-BE), and Wave 2+ RTL/CJK remain roadmap phases and are not designed here.

Timing decision. P0 starts now rather than after the A6 launch gate, with the C7 English Register R2 audit running in parallel. C7 must land before any non-English locale is enabled. The reasoning is that English wording changes are nearly free while en-AU is the only locale, and expensive once translations exist — every re-voiced English string invalidates its translation in every shipped language.

Working constraint. Feature work on other tracks (Care Pathways, Care Start, vitals) continues throughout. Extraction must therefore be incremental and conflict-tolerant; a codebase-wide freeze is not available.

TopicDecision
Clinical view toggleNot shipping — plain register only; REQ-I18N-18/19 and mandatory _clinical pairs deferred (doc 03 v1.7).
Observation instrumentsLynCareOS-owned carer-observation copy; Abbey/PAINAD/Rockwood/NRS are references only — no verbatim instrument lists (doc 03 v1.8, i18n-frontend.mdc).
Marketing hreflangIn scope for I18N-M1 — REQ-I18N-32a: locale path prefixes + link rel="alternate" hreflang including x-default.
Pre-login languageMarketing static HTML (marketing/palliative/) — detect + top-right picker; lyncareos_marketing_locale cookie flows into app bootstrap (doc 03).
Locale bundlesfr-FR stays enabled: false until product enables locally; non-English JSON is produced only when you ask — English extraction/CI still mandatory for new UI.
C7Run in parallel with P0; not a pre-launch blocker for English-only production.
PostgreSQL REINDEXStandard ops after VPS OS upgrade — 07-PLATFORM-RUNBOOK §18 (done 2026-08-03).

Measured against the repository on 2026-08-03. String and word counts below are regex-derived estimates (JSX text nodes, placeholder/aria-label/title/label props, and broad quoted literals). They guide planning only; the authoritative key count is i18next-cli status after the foundation PR lands.

MetricValue
.tsx files under frontend/src305 (52 pages, 197 components)
Lines of TypeScript under frontend/src~95,600
Candidate translatable strings (estimate)~3,270
Candidate source words (estimate)~13,700
Files containing JSX text or string props177
i18n dependencies present todaynone
tenants.locale / users.locale_overrideV031 (I18N-P1 engineering)

Planning figures after deduplication and false-positive filtering: 2,500–3,500 keys, 12,000–15,000 source words. This is a small-to-medium localisation project; the dominant cost is engineering, not volume.

Milestone A carries the whole programme’s engineering cost. Once extraction is complete and the plug-in model works, each additional Latin or Cyrillic locale is translation files plus a config flag, per REQ-I18N-33.


3.0 Translation happens once, ahead of time — never at runtime

Section titled “3.0 Translation happens once, ahead of time — never at runtime”

Stated explicitly because it underpins every other decision.

Translation is build-time. English strings are extracted once, translated once per locale, reviewed, committed to git, and bundled as static JSON. At runtime the app performs a dictionary lookup, not a translation: selecting French loads fr-FR/*.json (a few kB) and i18next resolves t('medication.dose.confirm_button') against it. There is no call to any translation service, no AI in the request path, no added latency, and it works offline in the PWA. The switch is instant and does not reload the app or end the session.

The AI translation described in §3.8 is an authoring tool used before release — analogous to using AI to help write code. It drafts locale JSON, a human reviews it, the result is committed. End users never interact with a translation model, and no user data ever reaches one.

DimensionOne-time / build-time (adopted)Real-time / on-the-fly (rejected)
When translation occursOnce per string, before releaseEvery page view, indefinitely
Runtime costZeroPer request, scales with usage
LatencyNone — local lookupNetwork round trip per screen
Offline / PWAWorksBreaks
DeterminismIdentical wording every timeMay vary between sessions
Human reviewYes, before shippingNone — unreviewed text reaches carers
Data exposureUI keys onlyContent leaves the platform — disqualifying, see §3.5

Two consequences.

  1. User content is never translated at any stage — not at build time, not at runtime. A care note typed in Russian is stored and displayed as Russian to every reader regardless of their UI language (§3.5, REQ-I18N-16).
  2. New features do not arrive translated. Strings added after a locale ships exist only in en-AU until translated, and fall back to English per REQ-I18N-03 in the meantime. This is the recurring maintenance load described in §3.8 and §6 — a direct consequence of this model, and the price of every advantage in the left-hand column above.

3.1 Library: react-i18next with the ICU plugin

Section titled “3.1 Library: react-i18next with the ICU plugin”

react-i18next remains correct for a Vite + React 19 SPA — it is the universal choice (~8M weekly downloads) and the alternatives that outperform it (next-intl) are Next.js-only. This confirms REQ-I18N-01.

Deviation added: the i18next-icu plugin is adopted from the first key. i18next’s native message format is non-standard where the localisation industry uses ICU MessageFormat, which creates friction with translation platforms. Since REQ-I18N-36 anticipates a TMS from I18N-P2a, standardising plurals and select syntax now costs nothing and avoids rewriting every plural in every locale later.

3.2 Extraction: i18next-cli in reviewed batches, behind two lint ratchets

Section titled “3.2 Extraction: i18next-cli in reviewed batches, behind two lint ratchets”

Custom ts-morph codemods are not required. The official i18next-cli (v1.47+) provides the whole toolchain:

NeedCommandRequirement satisfied
Codemod hardcoded strings into t()i18next-cli instrument—
Build namespace JSON from sourcei18next-cli extractREQ-I18N-02
Generate typed keysi18next-cli typesREQ-I18N-04
Detect remaining hardcoded stringsi18next-cli lint—
Per-namespace coverage reportingi18next-cli statusREQ-I18N-34

The maintainers’ own guidance matches the batch model: run --dry-run, then --interactive to approve each candidate, commit, then extract. They describe instrument as “a first-pass assistant, not a compiler” and require diff review.

Key naming stays human. instrument derives keys from content (a button reading “I am button” becomes iAmButton). Machine keys are effectively permanent — every locale file, TMS entry, and reviewer’s context is built on them — so each batch includes a pass renaming keys to semantic, hierarchical names (medication.dose.confirm_button).

Two ratchets, both modelled on the existing overlay z-index migration in frontend/eslint.config.js (rule on globally, shrinking list of exempt files, CI fails if the list grows):

  1. No literal user-facing text in src/pages and src/components (eslint-plugin-i18next no-literal-string).
  2. No physical-direction Tailwind classes (ml-, mr-, pl-, pr-, left-, right-, text-left, text-right) in favour of logical equivalents (ms-, me-, ps-, pe-, start-, end-, text-start, text-end) — REQ-I18N-12 / NFR-12.

Un-migrated files stay legal so feature work is never blocked; migrated files can never regress. Progress is monotonic by construction.

RTL readiness runs inside P0, not at Wave 2. Retrofitting logical CSS later means touching all 305 files a second time. No RTL locale ships in P0 or P1; only the CSS and component conventions land.

Roughly twenty day-sized PRs (~15 files each), one domain per batch, each adding namespace JSON and shrinking both ratchet exemption lists.

Batch 1 — app shell (mandatory first): components/layout, components/ui, components/brand, plus root-level auth/onboarding pages (Login.tsx, Register.tsx, PendingApproval.tsx, GettingStarted.tsx). Establishes bidi display conventions (§3.6) and key naming before the long tail.

Suggested batch spine (batches 2–20; merge small dirs where sensible):

BatchScopeNamespace(s)
2components/auth + pages/Account.tsxmodules/auth, common (account)
3components/settings + team/invite flowsmodules/settings
4components/billing + billing pagesmodules/billing
5components/dashboard + Dashboard.tsx, More.tsxmodules/dashboard
6components/medication, dose, logDose + LogDose.tsxmodules/medication
7components/scripts + Scripts.tsx, ScriptDetail.tsxmodules/scripts
8components/medication-schedule + MedicationSchedule.tsx, AutoDispense.tsxmodules/medication-schedule
9components/calendar + Calendar.tsx, Schedule.tsx, pages/calendar/*modules/calendar
10components/shopping + Shopping.tsxmodules/shopping
11components/vitals + VitalsTracking.tsxmodules/vitals
12components/pain + PainTracking.tsxmodules/pain
13components/observations + Observations.tsxmodules/observations
14components/familyHelp + HelpRequests.tsx, KeyContacts.tsxmodules/familyHelp
15components/sleep + SleepPattern.tsxmodules/sleep
16components/history + History.tsx, pages/history/*modules/history
17components/alerts, notificationsnotifications, errors (shared chrome)
18components/condition-packs, care-modules, care-capturemodules/condition-packs, clinical
19components/admin + pages/admin/*modules/admin
20components/charts, radar, remaining root pages, context/ copysweep + common/errors completion

Namespaces follow REQ-I18N-02: core common, clinical, errors, notifications, plus modules/{slug}.json per product domain. Adjust batch boundaries if a PR exceeds ~300 lines of meaningful diff.

Clinical-register strings use plain keys only for P0/P1 (REQ-I18N-02a deferred with the clinical toggle). Palliative Register R2 still applies to English seed copy during extraction.

3.4 Locale detection: browser language first, country as a weak hint

Section titled “3.4 Locale detection: browser language first, country as a weak hint”

This corrects a common but incorrect intuition that a user located in France should receive a French UI. Country is not language. The 2026 guidance is consistent: prioritise Accept-Language / navigator.languages over IP geolocation, and use geolocation only for regional formatting such as currency, never for language selection. VPNs, travel, expatriates, and diaspora households break country inference immediately.

This matters specifically for LynCareOS. Family carers include migrant and diaspora households — doc 03 itself uses the Russian-speaker-in-a-UK-household example. Under a country-first rule, a British family caring for a relative in France would receive a medication interface in French. That is a safety-relevant failure, not a cosmetic one.

Resolution order. Doc 03 §9 defines a four-step chain for the app and REQ-I18N-28 defines a five-step chain including a country hint for marketing. This design harmonises them on the marketing form, so app and marketing behave identically. The order must not be weakened during implementation:

  1. users.locale_override
  2. tenants.locale
  3. navigator.languages, matched against enabled locales
  4. Country hint (Cloudflare CF-IPCountry or existing IP pricing lookup), where the config defines a default locale for that country
  5. en-AU

Matching uses @formatjs/intl-localematcher rather than string comparison, so fr-CA resolves to fr-FR and en-IE to en-AU through CLDR rules (UTS #35). This is how REQ-I18N-06 locale inheritance is implemented in practice.

Where the country hint disagrees with the resolved language, the app shows a dismissible suggestion (“also available in Français”) rather than switching silently. The intended outcome is preserved — a person living in France almost always has French in their browser language list — while removing the failure mode where the guess is wrong.

The resolved locale is written to a cookie as well as the user profile, so the first paint after login does not flash English.

yes

no

yes

no

yes

no

yes

no

yes

no

App bootstrap or first visit

users.locale_override set?

Use override

tenants.locale set?

Use tenant default

Match navigator.languages via intl-localematcher

Enabled locale found?

Use matched locale

Country hint from config map

Default for country enabled?

Use country default

en-AU

Set cookie plus document lang and dir

Different from browser resolution?

Dismissible also-available suggestion

Render UI from static locale JSON

3.5 User content is never translated — a security boundary, not a preference

Section titled “3.5 User content is never translated — a security boundary, not a preference”

REQ-I18N-16’s frame-versus-content separation is restated here as a hard rule, because the healthcare research makes it a compliance control rather than a UX choice:

  • Health data is GDPR “special category” data. Sending patient-entered free text to any external translation service — a TMS, a machine-translation API, or an LLM — without a signed BAA or DPA is a direct GDPR and HIPAA exposure.
  • Measured machine-translation error rates on medical content run 2–8%, which is unacceptable for clinical text regardless of the legal position.

Rule: translation tooling — including AI models used under §3.8 — sees en-AU UI keys and nothing else, ever. No user content, no PHI, no database extract leaves the platform for translation purposes. This constrains any future TMS selection at I18N-P2a.

Storage is already correct and verified. Both the Docker UAT database (PostgreSQL 16.11) and production (16.14, verified read-only 2026-08-03) use UTF8 encoding, so text in any script stores losslessly today. No migration is required for content storage.

dir="auto" on user text inputs (REQ-I18N-20) is necessary but not sufficient. When RTL user content is displayed adjacent to LTR frame text, direction bleeds into surrounding layout unless each user string is isolated.

Convention, established in batch 1: wrap displayed user-entered content in <bdi> (or an element carrying dir="auto"); where user text is concatenated into a plain string, use Unicode isolation characters FSI (U+2068) and PDI (U+2069). This has no visible effect until Wave 2 but avoids a second pass over every component.

3.7 Collation caveat (operations, not i18n)

Section titled “3.7 Collation caveat (operations, not i18n)”

Both databases use glibc collation (en_US.utf8). Storage is unaffected, but sort order of non-ASCII text depends on the host’s glibc version, and a VPS OS upgrade can silently corrupt text indexes until a REINDEX. Changing collation requires recreating the database, so the correct response is a documented REINDEX step in the OS-upgrade procedure. The risk exists today; it becomes material once significant non-Latin data is held.

Action: Done — 07-PLATFORM-RUNBOOK.md §18, 11-DATABASE-SAFETY §2q, 20-PRODUCTION-DEPLOYMENT-GUIDE §7.

3.8 Translation quality model: AI consensus plus native review

Section titled “3.8 Translation quality model: AI consensus plus native review”

This deviates from doc 03 §7.8 as previously written (professional translator mandate). Doc 03 §7.8 / §7.8a was amended in v1.6 to match this model.

Evidence supporting the change:

  • LLMs reach 85–95% of professional human quality, and UI strings are the strongest case — “for UI strings, technical documentation, and help articles, AI quality often suffices without human review.” The residual 10–20% human advantage concentrates in marketing and creative copy.
  • Multi-model consensus (querying several independent engines and taking agreement) reduced visible errors and stylistic drift by 18–22% versus a single engine, with the largest gains in hallucinated content, dropped words, and terminology drift.
  • Human post-editing of LLM output adds roughly 8%, concentrated in naturalness and cultural fit — precisely what a machine cannot self-assess.
  • Doc 03’s Tier 2 standard is already “translator plus lay carer native review,” tested by “would a family member say this?” A native-speaker family carer is better placed to make that register judgement than a certified medical translator, who tends to correct toward clinical register.

Model adopted:

TierContentProductionReview
1 — UI chromeNav, buttons, settings, errorsMulti-model AI consensus + automated back-translation diffNative-speaker spot review: every high-risk string plus a sample of ≥10% of keys per namespace
2 — Plain clinicalPrompts, observation labels (plain keys)Multi-model AI consensusMandatory native lay-carer review, reviewer ≠ translator
3 — Verbatim validated instruments (exception)Official Abbey/PAINAD/Rockwood/NRS text only if product opts inNot translated by AI or volunteersLicence + official translation; not the default product path

Carer-observation default (doc 03 v1.8): Future modules use LynCareOS-owned descriptors inspired by literature — Tier 2 — avoiding verbatim instrument reproduction. See Appendix A and i18n-frontend.mdc.

Three controls make the zero-cash model safe:

  1. Glossary and do-not-translate list, built during P0 while English keys are being written. Volunteer and AI translation both drift on terminology without one.
  2. Automated back-translation diff in CI — machine catches semantic drift so humans do not have to read 3,000 strings.
  3. High-risk string set — anything concerning dose, timing, allergy, or emergency contact always receives human review from a second person, with the reviewer never being the translator.

Sustainability risk, stated explicitly. This is a permanent obligation, not a one-off favour. Community-translation experience is consistent: a motivated volunteer translates a large chunk over a weekend and then abandons it, leaving fragmented strings; the Scratch Foundation found 3–12 people per language are needed to sustain the effort. Every release adds strings. The mitigation is to keep the enabled locale count small until a market justifies the permanent maintenance load, and to let CI coverage gates block a locale rather than shipping it half-translated.

Tooling. glossboss (open source) handles i18next JSON natively, supports DeepL, OpenAI, Claude and Gemini, and provides translation memory, glossary conflict checks, ICU variable drift detection, and a review workflow with GitHub sync. It replaces the paid TMS line item for P0–P1.


4.1 Foundation change set (touches almost no existing files)

Section titled “4.1 Foundation change set (touches almost no existing files)”
ArtefactPurpose
frontend/src/lib/i18n.tsi18next init, ICU plugin, detector chain (§3.4), changeLanguage wrapper
frontend/src/locales/en-AU/{common,clinical,errors,notifications}.jsonCore namespaces (REQ-I18N-02)
frontend/src/locales/locales.config.jsonen-AU only, full REQ-I18N-05 shape: nativeDisplayName, flagEmoji, direction, extends, enabled, date/time/number formats, week start, emergency number, terminology map
Generated resources.d.ts + i18next CustomTypeOptionsTyped keys; t() typos become build errors (REQ-I18N-04)
i18next.config.tsi18next-cli configuration
ESLint ratchet configs + baseline lists§3.2
frontend/src/locales/glossary.jsonTermbase and do-not-translate list (§3.8)

Runtime behaviour implemented once and not revisited: the REQ-I18N-03 fallback chain with the visible [MISSING: key] sentinel, and the REQ-I18N-35 three-second lazy-load timeout falling back to en-AU per namespace.

Twenty batches per §3.3. Each batch: instrument --dry-run, instrument --interactive, semantic key rename, interpolation and plural fixes, extract, types, shrink both ratchet lists, merge. Run npm run validate:architecture in frontend/ before merge on every batch.

The design references “CI blocks the flip” (REQ-I18N-34) and ratchets (§3.2). Wire them into the repo’s existing automation — do not invent a parallel process.

Local — scripts/run-quality-gates.ps1 (today: Ruff, Router SQL, Tenant isolation, Audit trail, SELECT *, Pytest, ESLint strict, OpenAPI type drift, Vitest). Add Run-Step entries in the foundation PR or first ratchet PR:

StepCommand / scriptPurpose
i18n coveragenpx i18next-cli status (fail under §7.8 thresholds when checking release branches)REQ-I18N-34
i18n lint ratchetESLint with shrinking exempt list for eslint-plugin-i18nextNo new hardcoded frame strings in migrated files
logical-CSS ratchetESLint rule + baseline JSON (same pattern as overlay z-index exempt list in frontend/eslint.config.js)REQ-I18N-12 / NFR-12
back-translation difffrontend/scripts/ gate script (P1): diff machine back-translation of locale JSON vs en-AU§3.8 control 2

CI — .github/workflows/ci.yml (jobs today: ruff, knowledge-alignment, pytest, openapi-contracts, vitest, eslint, …):

  • Ratchets ride the existing eslint job once rules and baselines live in eslint.config.js.
  • Add a dedicated i18n job (or extend vitest only if it stays fast): i18next-cli status, optional pseudo-localisation check, back-translation diff on PRs touching frontend/src/locales/.
  • Document new steps in 12-CI-REFERENCE.md in the same change set that adds the job.

Architecture ESLint: npm run validate:architecture on src/pages and src/components must stay green throughout the sweep (repo Definition of Done; not inside run-quality-gates.ps1 today).

Vitest and Playwright (npm run test, npm run test:e2e, test:regression) assert on visible English copy today. Extraction must keep en-AU user-visible output identical to pre-extraction wording unless C7 deliberately re-voices a string.

SituationPolicy
Test selects by t() key or role/name from unchanged EnglishUpdate locator only if the accessibility name changes
Snapshot or string equality on frame copyFix in the same batch as the extraction that changed the source
C7 changes English after keys existUpdate en-AU JSON + tests + any enabled locale in one change set
Flaky testNever weaken an assertion to green the build; fix the test or the copy

Playwright locale smoke pack (I18N-P1+): npm run test:e2e:i18n — language-agnostic coverage of switcher + html lang persistence, chrome nav.home, day-strip month label, and timeFormat 12h/24h config contract for every enabled non-default locale (e2e/i18n-locale-smoke.spec.ts). Not a full UI crawl.

  • No hardcoded user-facing strings remain in src/pages or src/components except two intentional permanent ESLint ratchet exempts: BrandWordmark (brand identity) and ShoppingCatalogAdmin (catalog l10n deferred per §7). Ratchet lists are not empty by design.
  • i18next-cli status reports 100% en-AU coverage across every namespace (plain keys; _clinical not required while toggle deferred).
  • Missing-key smoke test renders the sentinel, not a blank or an error boundary.
  • Pseudo-localisation runs clean within the doc 03 §11 expansion caps (150% UI chrome, 200% labels and buttons).
  • C7 Register R2 audit complete or explicitly signed off as not blocking.

I18N-P0 extraction exit (2026-08-04): batches 1–20 complete; Vitest 482+; validate:architecture green; ratchet 2/2 permanent exempts only.


GET /api/auth/me and PATCH /api/auth/me already exist, with a ProfileUpdate model and an update_profile service, and /me is already the app-load bootstrap call. Locale persistence extends that path rather than adding new plumbing.

ChangeDetail
V031__i18n_locale_columns.sqltenants.locale TEXT NOT NULL DEFAULT 'en-AU'; users.locale_override TEXT NULL
Migration registerRow added to doc 11 §1a; DDL mirrored into backend/schema.sql
models.pylocale_override on ProfileUpdate and UserProfile; effective locale on the /me payload
Service / repositoryupdate_profile handles locale_override; repository performs the write, scoped by tenant_id
Tenant defaulttenants.locale editable by tenant admins in Settings (e.g. Account / settings surfaces)

Returning the resolved effective locale from /me means the client never recomputes the chain.

OpenAPI contract (mandatory in the same commit as model changes). Adding fields to ProfileUpdate / UserProfile changes the published schema. REQ-PLAT-10 / B1 and CI job openapi-contracts fail on drift unless you regenerate and commit together:

Terminal window
python backend/scripts/export_openapi.py
cd frontend; npm run generate:types

Commit openapi/openapi.json and frontend/src/lib/api.types.ts together. Add a named alias in frontend/src/lib/api.contracts.ts for any new response fields the client uses (e.g. effective locale); use import type in frontend/src/lib/api.ts — do not hand-edit api.types.ts.

Audit and tenant isolation. Locale preference is not patient-linked clinical data. Updating users.locale_override or reading effective locale for UI bootstrap does not require an audit log entry under the clinical mutation rules in .cursor/rules/rules.mdc. Reviewers and scripts/check_audit_trail.py should treat these endpoints as profile preference, not dispensings/prescriptions/care shifts. tenants.locale writes are tenant-admin only, scoped by tenant_id in the service/repository layer; users.locale_override updates only the authenticated user’s row.

frontend/src/components/i18n/LanguageSwitcher.tsx — presentation only, reading enabled locales from locales.config.json.

Visibility. When only en-AU is enabled, the control is hidden (no pointless single-language picker). It appears when two or more enabled locales exist — same rule as marketing REQ-I18N-26 / REQ-I18N-27.

Overlay compliance. The open picker is an overlay. Follow 04-OVERLAY-REGISTER.md: short centred pickers are tier D1 (Modal.tsx or listbox with equivalent a11y). Placement is in MobileTopBar.tsx / desktop chrome (z-chrome, 40). The picker panel and backdrop must use a named rung from frontend/tailwind.config.js above z-chrome (e.g. z-sheet / z-dialog) — not ad-hoc z-[N]. Use TenantSwitcher.tsx as the interaction precedent for header placement; do not copy its dismiss layer at z-40 tying the top bar (documented open defect in the overlay register).

ElementBehaviour
Closed controlflagEmoji + nativeDisplayName + chevron (REQ-I18N-22)
Open pickerEvery enabled locale; native name primary, gloss in active UI language secondary, checkmark on current row (REQ-I18N-23)
SortAlphabetical by nativeDisplayName via Intl.Collator — never by flag, country, or market priority (REQ-I18N-31)
PlacementTop app bar, plus Settings → Language on Account or equivalent (REQ-I18N-21)
On selectchangeLanguage, update documentElement.lang and dir, aria-live announcement, persist to profile, no logout, other household members unaffected (REQ-I18N-24)
Override noticeSettings explains when the personal language differs from the family default, with a reset action (REQ-I18N-25)
Accessibilityaria-haspopup, aria-expanded, aria-current; focus trap; Escape closes; rows ≥44 px

5.3 Display formatting and terminology (REQ-I18N-07, REQ-I18N-08)

Section titled “5.3 Display formatting and terminology (REQ-I18N-07, REQ-I18N-08)”

Doc 03 §10 assigns I18N-P1: format dates, numbers, and relative times from locale config; regional terms from the terminology map — not hardcoded “GP” / “PBS” strings in components.

AreaApproach
Dates and timesPrefer Intl.DateTimeFormat, Intl.NumberFormat, Intl.RelativeTimeFormat with locales.config.json options (week start, 12/24h). API continues to return UTC ISO strings and raw numbers.
date-fnsRepo already depends on date-fns v4. Introduce a small helper (e.g. lib/formatLocale.ts) that picks date-fns/locale/* from the active BCP-47 tag or delegates display-only paths to Intl — avoid two conflicting formats on the same screen.
TerminologyRead regional labels from locales.config.json → terminology (REQ-I18N-08); keys in JSON reference terminology slots, not inline country-specific nouns.
Scope for P1Calendar, medication schedule, billing/Stripe display, and settings surfaces first; expand with each module batch if any remain English-formatted at P1 ship.

fr-FR covering Tier 1 and Tier 2 per the §3.8 model. Tier 3 scales use published validated translations or fall back to English. en-AU must report 100% coverage before fr-FR may be set enabled: true; the i18n CI job / i18next-cli status gate blocks the flip (REQ-I18N-34).

  • A user switches en-AU ↔ fr-FR; UI changes immediately; reload preserves the choice; a second user in the same household still sees the tenant default.
  • Lazy-load failure simulation falls back to en-AU within three seconds without breaking the shell.
  • Native lay-carer review of Tier 2 French complete; high-risk string set reviewed by a second person.
  • Back-translation diff clean, or every flagged divergence explicitly accepted.

5.6 Service worker, caching, and deploy verification

Section titled “5.6 Service worker, caching, and deploy verification”

Locale strings are static assets, not a runtime translation API. Default implementation for P0/P1:

  • Primary path: import locale namespaces via Vite so JSON is content-hashed under /assets/ and participates in normal SPA cache busting on each production build.
  • Lazy-load path (REQ-I18N-35): if a namespace is loaded with import() at runtime, treat failed/slow fetch like doc 03 — fall back to en-AU within 3s; do not add locale JSON to the service worker precache list unless product explicitly requires offline-first for non-English (would require versioned precache updates per locale ship).

frontend/public/sw.js precaches APP_SHELL and uses runtime caching for navigations. Do not rely on stale SW caches for index.html / sw.js — production already uses no-store on the shell (production-deploy-cache.mdc). Any i18n release that changes UI copy is a UI release: after VPS deploy, verify new CACHE_NAME on https://app.lyncareos.com/sw.js, no-store on /, and API smoke — same gate as other frontend ships.

The offline claim in §3.0 holds when the active locale bundle is either in the main chunk graph or successfully lazy-loaded once; it does not require live translation services.


ItemCost
I18N-P0 engineering tooling$0 — open source
French translation (§3.8 model)$0 cash; native-speaker review time
TMS$0 — glossboss, self-hosted or local
Infrastructure$0 — static JSON on existing hosting; marginal bundle increase
Tier 3 validated scalesPermission and possible commercial licence fees, when those scales ship — independent of language
RecurringEvery release adds strings across every enabled locale, forever

For reference, the professional alternative would be roughly USD $2,500–$5,000 per language all-in, or $18,000–$35,000 for all seven Wave 1b languages.


Tracked as existing roadmap phases, not designed here:

  • I18N-BE — backend notification, email, and API error strings (REQ-I18N-11)
  • I18N-M1 — marketing site language picker (REQ-I18N-26…30, 32, 32a, 37); hreflang and locale URL prefixes in scope (REQ-I18N-32a)
  • I18N-P0v — English regional variants (en-GB, en-US, …) as extends overrides
  • I18N-P2a/P2b — Wave 1b locale plug-ins
  • I18N-P4 — Wave 2+ RTL (Arabic) and CJK. Bidi conventions land in P0; no RTL locale ships.
  • Shopping catalog UI locale — backend V012 accepts ?locale= on catalog APIs; UI remains English until a dedicated shopping l10n pass (doc 03 §2.1 deferral). Do not block P0/P1 on catalog string extraction unless product reprioritises.

RiskMitigation
Extraction stalls partway, leaving a half-migrated codebaseRatchet lists make progress monotonic and visible; each batch is independently shippable
Machine-generated key names become permanentSemantic rename pass is mandatory in every batch before merge
English re-voicing after translation existsC7 runs in parallel with P0 and gates the first non-English locale
Volunteer reviewer availability lapsesCI coverage gate blocks enabling a locale rather than shipping it partial; keep locale count small
Terminology drift across AI and volunteer contributionsGlossary and do-not-translate list from P0; glossboss glossary conflict checks
Mistranslated safety-critical stringHigh-risk string set with mandatory second-person review; back-translation diff in CI
Merge conflicts with parallel feature workOne domain per batch, day-sized PRs
glibc collation drift on OS upgradeREINDEX in runbook §18 + doc 11 §2q (documented)

DocumentChangeWhen
03-REQUIREMENTS-INTERNATIONAL-LANGUAGE.md §7.8Replace the professional-translator mandate with the §3.8 AI-consensus plus native-review model and its three controlsDone — doc 03 v1.6
Doc 03 §4 current stateUpdate once P0 landsEnd of P0
Doc 03 §7.1 / REQ-I18N-01Note i18next-icu adoption and the i18next-cli toolchainDone — doc 03 v1.6
Doc 03 §9 effective locale resolutionAdd the country-hint step so the app chain matches REQ-I18N-28 (§3.4)Done — doc 03 v1.6
12-CI-REFERENCE.mdDocument new i18n CI job and local gate parityWhen CI job lands
Project Motherboard / knowledge alignmentRun .\scripts\run-knowledge-assessment.ps1 after doc 03 v1.6; reports under knowledge/reports/; CI knowledge-alignment jobAfter doc 03 publish (same release as design v1.2)
04-ROADMAP §15Status Not started → In progressP0 start
01-ARCHITECTURE.md Internationalisation sectionCurrent state and the new tenants.locale / users.locale_override columnsEnd of P1
doc 11 §1aRegister V031__i18n_locale_columns.sqlWith the migration
07-PLATFORM-RUNBOOK.mdREINDEX step in the OS-upgrade procedure (§3.7)Done — §18
31 delivery register §2.41REQ-I18N status updatesPer phase

Order-of-magnitude for scheduling; not a commitment.

PhaseDurationNotes
Foundation PR~1 weeki18next stack, ratchet baselines, empty en-AU namespaces, first i18next-cli status baseline
P0 sweep~6–10 weeks part-time~20 batches per §3.3; parallel feature work continues
P1~2–3 weeks after P0 exitMigration, OpenAPI regen, switcher, fr-FR bundle, review gates, Playwright switcher test
C7Parallel with P0Gates first non-English locale enable

Section titled “Appendix A — Carer-observation instruments (copyright)”

Product default (2026-08-03): Abbey, PAINAD, Rockwood CFS, branded NRS/VAS, MMSE, Borg, etc. are design references only. Ship LynCareOS-original item lists and descriptors (Tier 2 lay review + i18n). Do not paste official validated instrument text into UI or locale JSON unless product explicitly opts into the Tier 3 verbatim exception (licence + official translations).

StatusExamplesi18n / legal
Live UI todayGeneric 0–10 pain bar; custom scale_1_5 / scale_1_10 observationsTier 2 — our wording
Future modulesObservational distress, frailty snapshots (REQ-NVPAIN-01, REQ-FRAILTY-01)LynCareOS-owned models — original copy; inspired-by noted in module spec
Verbatim instrumentsOnly if product requires official scale textTier 3 exception — not base product

Agent rule: .cursor/rules/i18n-frontend.mdc.


DateVersionChange
2026-08-041.5I18N-P0 extraction complete (§3.3 batches 1–20); §4.6 amended for permanent ratchet exempts; P1 engineering started (V031 locale columns, /me effective locale, switcher + Account language section, formatLocale.ts).
2026-08-031.4Foundation landed: react-i18next+i18next-icu, lib/i18n.ts (static en-AU, lazy non-default, REQ-I18N-03 sentinel, REQ-I18N-35 timeout, §3.4 detection stub), locales.config.json (REQ-I18N-05), typed keys (@types/i18next.d.ts), i18next.config.ts, ESLint i18n ratchets + check_i18n_eslint_ratchet.py. Verified: tsc -b, Vitest 482, i18next-cli status 0 keys. §1 status updated.
2026-08-031.3§1.1 product decisions (no clinical toggle, hreflang in M1, marketing cookie, translate-on-demand, REINDEX ops done). §1.1 LynCareOS-owned observation instruments. Appendix A rewritten. Tooling: ESLint ratchets landed (foundation).
2026-08-031.2Re-review: §4.4–4.6 quality gates/CI, test impact, renumbered exit; §5.1 OpenAPI regen, audit/tenant posture; §5.2 overlay D1 + visibility rule; §5.3 Intl/terminology; §5.5–5.6 renumber + service worker/deploy cache; §2 measurement caveat; §3.3 batch spine table; §3.4 mermaid resolution; §7 shopping catalog deferral; §9 knowledge alignment + doc 03 done rows; §10 effort estimate.
2026-08-031.1Added §3.0 — translation is build-time, not runtime; contrast with the rejected real-time model; consequences for user content and for newly added strings.
2026-08-031.0Initial design. Approach, tooling, detection chain, security boundary, and zero-cash translation model approved.