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:
@@ -195,23 +195,32 @@ export function getWebviewHtml(options: WebviewHtmlOptions): string {
|
||||
initialSessionId: ${initialSessionId ? `"${initialSessionId.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"` : 'null'},
|
||||
};
|
||||
window.__OPENCHAMBER_HOME__ = "${workspaceFolder.replace(/\\/g, '\\\\')}";
|
||||
|
||||
function getBootstrapMessages() {
|
||||
var locale = 'en';
|
||||
// VS Code's display language. The UI bundle uses it as the default locale
|
||||
// until the user picks one; the splash below picks its strings from it too.
|
||||
window.__OPENCHAMBER_HOST_LANGUAGE__ = ${JSON.stringify(vscode.env.language)};
|
||||
|
||||
// OpenChamber's own saved locale wins; before one exists, VS Code's display
|
||||
// language decides, so a fresh install in a supported language never boots
|
||||
// in English.
|
||||
function resolveBootstrapLanguage() {
|
||||
try {
|
||||
var rawLocale = window.localStorage.getItem('openchamber.i18n.v1');
|
||||
if (rawLocale) {
|
||||
var parsedLocale = JSON.parse(rawLocale);
|
||||
if (parsedLocale && typeof parsedLocale.locale === 'string') {
|
||||
var detected = parsedLocale.locale.toLowerCase();
|
||||
if (detected.indexOf('fr') === 0) {
|
||||
locale = 'fr';
|
||||
} else if (detected.indexOf('tr') === 0) {
|
||||
locale = 'tr';
|
||||
}
|
||||
}
|
||||
if (parsedLocale && typeof parsedLocale.locale === 'string') return parsedLocale.locale.toLowerCase();
|
||||
}
|
||||
} catch {}
|
||||
return String(window.__OPENCHAMBER_HOST_LANGUAGE__ || '').toLowerCase();
|
||||
}
|
||||
|
||||
function getBootstrapMessages() {
|
||||
var locale = 'en';
|
||||
var detected = resolveBootstrapLanguage();
|
||||
if (detected.indexOf('fr') === 0) {
|
||||
locale = 'fr';
|
||||
} else if (detected.indexOf('tr') === 0) {
|
||||
locale = 'tr';
|
||||
}
|
||||
|
||||
if (locale === 'fr') {
|
||||
return {
|
||||
@@ -296,27 +305,19 @@ export function getWebviewHtml(options: WebviewHtmlOptions): string {
|
||||
|
||||
const statusEl = document.getElementById('loading-status');
|
||||
const getDevMessages = () => {
|
||||
try {
|
||||
const rawLocale = window.localStorage.getItem('openchamber.i18n.v1');
|
||||
if (rawLocale) {
|
||||
const parsedLocale = JSON.parse(rawLocale);
|
||||
if (parsedLocale && typeof parsedLocale.locale === 'string') {
|
||||
const detected = parsedLocale.locale.toLowerCase();
|
||||
if (detected.indexOf('fr') === 0) {
|
||||
return {
|
||||
startingDevServer: (host) => 'Démarrage du serveur de développement de la webview (' + host + ')...',
|
||||
waitingDevServer: (host, attempt) => 'En attente du serveur de développement de la webview (' + host + ')... tentative ' + attempt,
|
||||
};
|
||||
}
|
||||
if (detected.indexOf('tr') === 0) {
|
||||
return {
|
||||
startingDevServer: (host) => 'Webview dev sunucusu başlatılıyor (' + host + ')...',
|
||||
waitingDevServer: (host, attempt) => 'Webview dev sunucusu bekleniyor (' + host + ')... deneme ' + attempt,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
const detected = resolveBootstrapLanguage();
|
||||
if (detected.indexOf('fr') === 0) {
|
||||
return {
|
||||
startingDevServer: (host) => 'Démarrage du serveur de développement de la webview (' + host + ')...',
|
||||
waitingDevServer: (host, attempt) => 'En attente du serveur de développement de la webview (' + host + ')... tentative ' + attempt,
|
||||
};
|
||||
}
|
||||
if (detected.indexOf('tr') === 0) {
|
||||
return {
|
||||
startingDevServer: (host) => 'Webview dev sunucusu başlatılıyor (' + host + ')...',
|
||||
waitingDevServer: (host, attempt) => 'Webview dev sunucusu bekleniyor (' + host + ')... deneme ' + attempt,
|
||||
};
|
||||
}
|
||||
return {
|
||||
startingDevServer: (host) => 'Starting webview dev server (' + host + ')...',
|
||||
waitingDevServer: (host, attempt) => 'Waiting for webview dev server (' + host + ')... attempt ' + attempt,
|
||||
|
||||
Reference in New Issue
Block a user