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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user