INNER CODE UNIT · TypeScript

loadLocaleMessages

opensquilla/opensquilla · opensquilla-webui/src/i18n/index.ts:67

export async function loadLocaleMessages(code: LocaleCode): Promise<void> {
  if (loaded.has(code)) return
  const loader = loaders[code as Exclude<LocaleCode, typeof DEFAULT_LOCALE>]
  if (!loader) return
  const mod = await loader()
  i18n.global.setLocaleMessage(code, mod.default)
  loaded.add(code)
}

/**
 * Resolve the initial locale, first match wins:
 *   1. saved preference (localStorage)
 *   2. host OS locale (Platform.getOsLocale, desktop) — passed in by the store
 *   3. server/desktop-injected #opensquilla-data data-locale
 *   4. <html lang> (set by the gateway template / pre-paint guard)
 *   5. navigator.languages
 *   6. DEFAULT_LOCALE
 * The OS locale precedes data-locale because the desktop gateway injects a

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…