fix: default app language to English

Stop auto-detecting locale from system/browser on first launch
Use saved language preference when users explicitly choose one
This commit is contained in:
Bohdan Triapitsyn
2026-04-28 15:40:21 +03:00
parent 3ae3c526cf
commit 8861f79708
-24
View File
@@ -78,35 +78,11 @@ export function writeStoredLocale(locale: Locale): void {
}
}
function getRuntimeLanguage(): string | undefined {
if (typeof window === 'undefined') {
return undefined;
}
return (window as unknown as { __OPENCHAMBER_RUNTIME_APIS__?: { runtime?: { language?: string } } })
.__OPENCHAMBER_RUNTIME_APIS__?.runtime?.language;
}
export function detectInitialLocale(): Locale {
const stored = readStoredLocale();
if (stored) {
return stored;
}
const runtimeLanguage = getRuntimeLanguage();
if (runtimeLanguage) {
return normalizeLocale(runtimeLanguage);
}
if (typeof navigator !== 'undefined') {
const languages = navigator.languages?.length ? navigator.languages : [navigator.language];
for (const language of languages) {
const locale = normalizeLocale(language);
if (locale !== DEFAULT_LOCALE) {
return locale;
}
}
}
return DEFAULT_LOCALE;
}