INNER CODE UNIT · TypeScript
resolveInitialLocale
opensquilla/opensquilla · opensquilla-webui/src/i18n/index.ts:87
export function resolveInitialLocale(osLocale?: string | null): LocaleCode {
try {
const saved = localStorage.getItem('opensquilla-locale')
if (isSupportedLocale(saved)) return saved
} catch {
// localStorage unavailable (private mode) — fall through
}
const os = normalizeLocale(osLocale)
if (os) return os
try {
const data = document.getElementById('opensquilla-data')?.dataset.locale
if (isSupportedLocale(data)) return data
} catch {
// ignore
}