Skip to main content

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)​

ConcernPath
Generated locale types + loaderssrc/i18n/i18n-types.ts, src/i18n/i18n-util.async.ts
English bundled catalogsrc/i18n/en/index.ts (via i18n-en-catalog source)
Supported locale manifestsrc/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 Englishsrc/i18n/idling-server-i18n.ts → getServerLL()
Quote shard alignmentsrc/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_CATALOG in idlingLocaleCatalog.ts (typed as IdlingLocaleId = typesafe-i18n Locales)

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):

LayerCommandRole
Full refreshpnpm l10n:refreshQuotes → UI strings → sync → generate
UI onlypnpm i18n:translateIncremental UI path
Quotes onlypnpm quotes:translateIncremental quote bodies
Offlinepnpm l10n:refresh:sync-enMirror EN until MT is back

Agent sequence after editing i18n-en-catalog:

  1. pnpm i18n:bootstrap-site
  2. pnpm 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 from navigator.language on every cold visit.
  • Async load uses loadLocaleAsync + sequence guard (loadSeq ref) so stale fetches cannot overwrite a newer picker choice.
  • Do not block the app shell on async locale fetch (loading flag 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​

Surfacei18n source
Site chrometypesafe-i18n ll.*
Tools (/card-generator, /svg-converter)ToolsCopyProvider + tools catalog
Radio chromeuseRadioCopy / widget catalogs under src/widgets/radio-player/
Message tickerll.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:*)