Internationalization
What this page is about: how UI locales are stored, refreshed, and loaded on idling.app — adapted from repo-root docs/i18n.md for the docs hub.
English is the source catalog for site chrome, managed with typesafe-i18n.
File layout (audited)
| Concern | Path |
|---|---|
| Generated locale types + loaders | src/i18n/i18n-types.ts, src/i18n/i18n-util.async.ts |
| English bundled catalog | src/i18n/en/index.ts (via i18n-en-catalog source) |
| Supported locale manifest | src/i18n/supported-locales.json |
| Canon locale rows (labels, BCP47, direction) | src/molecules/quotes/idlingLocaleCatalog.ts |
Client init + getLL() | src/i18n/idling-i18n.ts |
| Server-only metadata English | src/i18n/idling-server-i18n.ts → getServerLL() |
| Quote shard alignment | src/data/quotes/locales/*.json (see Quotes) |
IDLING_UI_LOCALE_STORAGE_KEY is idling-ui-locale (src/molecules/quotes/resolveIdlingLocale.ts). Picker commits via writeIdlingLocaleCookie.
Supported locales
- Manifest:
src/i18n/supported-locales.json - Runtime catalog:
IDLING_LOCALE_CATALOGinidlingLocaleCatalog.ts(typed asIdlingLocaleId= typesafe-i18nLocales)
Commands
pnpm l10n:refresh # quotes + UI via LibreTranslate (falls back to EN sync)
pnpm l10n:refresh:sync-en # offline: mirror EN into all locale files
pnpm i18n:translate # UI chrome only
pnpm quotes:translate # quote bodies only
pnpm i18n:bootstrap-site # rebuild en.json from source catalogs
pnpm i18n:generate && pnpm i18n:sync
Machine translation uses self-hosted LibreTranslate on port 5000 in the Docker stack.
After catalog or en.json changes (agents)
Prefer the batch MT stack (LibreTranslate on :5000, ledgers in translation-meta.json):
| Layer | Command | Role |
|---|---|---|
| Full refresh | pnpm l10n:refresh | Quotes → UI strings → sync → generate |
| UI only | pnpm i18n:translate | Incremental UI path |
| Quotes only | pnpm quotes:translate | Incremental quote bodies |
| Offline | pnpm l10n:refresh:sync-en | Mirror EN until MT is back |
Agent sequence after editing i18n-en-catalog:
pnpm i18n:bootstrap-sitepnpm l10n:refresh
Runtime policy (IdlingLocaleProvider)
Implementation: src/app/components/locale/IdlingLocaleProvider.tsx.
- English sync on first paint via
initIdlingI18n(IDLING_BASE_LOCALE). - Other locales load when the footer picker changes locale or when deferred
localStorage(idling-ui-locale) resolves — not fromnavigator.languageon every cold visit. - Async load uses
loadLocaleAsync+ sequence guard (loadSeqref) so stale fetches cannot overwrite a newer picker choice. - Do not block the app shell on async locale fetch (
loadingflag is available but chrome renders in English first).
Server / metadata
getServerLL() is cache()d sync English only for RSC metadata — never loadLocaleAsync on the server. See SSR metadata gotcha.
Feature copy surfaces
| Surface | i18n source |
|---|---|
| Site chrome | typesafe-i18n ll.* |
Tools (/card-generator, /svg-converter) | ToolsCopyProvider + tools catalog |
| Radio chrome | useRadioCopy / widget catalogs under src/widgets/radio-player/ |
| Message ticker | ll.messageTicker.* + quote shards |
Hub feature docs: Idling application.
Source of truth in repo
Full operator detail remains in docs/i18n.md at repo root (not scanned by Docusaurus). This hub page is kept in sync with that file.
Sources: src/i18n/supported-locales.json, src/molecules/quotes/idlingLocaleCatalog.ts, src/app/components/locale/IdlingLocaleProvider.tsx, src/i18n/idling-server-i18n.ts, package.json (l10n:*, i18n:*)