fix(vscode): default to the VS Code display language before a saved locale

The splash and the UI bundle both started in English on a fresh install
even when VS Code ran in a supported language, because only OpenChamber's
own saved locale was consulted. The HTML now exposes VS Code's display
language; the splash and detectInitialLocale use it until the user picks
a locale, which still wins.

Claude-Session: https://claude.ai/code/session_01VqV56Hez25hTxXH4ipJfzH
This commit is contained in:
Bohdan Triapitsyn
2026-09-05 15:08:15 +03:00
parent 319cf9f17a
commit c3a83b3181
3 changed files with 52 additions and 35 deletions
+12
View File
@@ -102,11 +102,23 @@ export function writeStoredLocale(locale: Locale): void {
}
}
declare global {
interface Window {
/** The host application's display language (VS Code sets it), used before the user picks a locale. */
__OPENCHAMBER_HOST_LANGUAGE__?: string;
}
}
export function detectInitialLocale(): Locale {
const stored = readStoredLocale();
if (stored) {
return stored;
}
const hostLanguage = globalThis.window?.__OPENCHAMBER_HOST_LANGUAGE__;
if (hostLanguage) {
return normalizeLocale(hostLanguage);
}
return DEFAULT_LOCALE;
}