Files
platform/src/apps/officer-web/lib/locales.ts
T
pastilhasandClaude Opus 5 1600a57b66 add swedish (sv-SE) locale — all three catalogues, wired in all four registration points
538 app.* + 541 panel.* + 43 ui.* = 1122 keys, full parity with en-GB. Registered in
catalogues.ts, locales.ts SHIPPED_LOCALES, and both workspace locales/index.ts —
the four-edit checklist docs/localization.md calls out, since a missed import is
what shipped es-ES/de-DE/fr-FR dead the first time.

files.menu.selected (officerdev) was number-invariant in English ("selected") but
needs one/other in Swedish ("vald"/"valda"), same class of bug as the "1
seleccionados" fix in es-ES — split it rather than copying the English shape.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 01:59:09 +00:00

28 lines
1.3 KiB
TypeScript

/**
* The UI locales that actually ship — regional BCP 47 tags, per docs/localization.md D2. This is the
* one list `I18nBridge` merges catalogs for and `Languages.tsx` offers for UI localization; it is
* deliberately separate from the broader "languages you speak" / "translate to" lists, which are a
* different feature (see the doc's open question 4) and are not limited to locales with a catalog.
*/
export type ShippedLocale = { code: string; label: string };
/**
* The label is an AUTONYM — each language named in its own language, so "Português" reads as Portuguese
* whichever locale the UI is currently in. That is the convention for a language picker and it is the
* useful behaviour: somebody who cannot read the current language still has to find theirs.
*
* Computed rather than written down, for the same reason the spoken-language list is (see Languages.tsx):
* `Intl` already knows every language's name in every locale, including its own.
*/
const autonym = (code: string): string => {
const name = new Intl.DisplayNames([code], { type: 'language', fallback: 'code' }).of(code) ?? code;
return name.charAt(0).toUpperCase() + name.slice(1);
};
export const SHIPPED_LOCALES: ShippedLocale[] = ['en-GB', 'pt-PT', 'fr-FR', 'de-DE', 'es-ES', 'sv-SE'].map((code) => ({
code,
label: autonym(code),
}));
export const FALLBACK_LOCALE = 'en-GB';