fix(webui): complete i18n audit

This commit is contained in:
chengyongru
2026-08-03 17:53:33 +08:00
committed by chengyongru
parent df11fd92a6
commit 2b63715282
22 changed files with 1535 additions and 994 deletions
+84 -5
View File
@@ -236,6 +236,72 @@ const LOCALIZED_CHANNEL_SHELL_KEYS = [
"settings.channels.validation.unsupported",
"settings.channels.validationFailed",
];
const LOCALIZED_NEW_SURFACE_KEYS = [
"chat.activity.running",
"chat.activity.complete",
"chat.activity.updated",
"chat.pin",
"chat.unpin",
"chat.rename",
"chat.renameProjectTitle",
"chat.renameProjectDescription",
"chat.renameProjectPlaceholder",
"chat.renameSave",
"chat.archive",
"chat.unarchive",
"chat.showArchived",
"chat.hideArchived",
"chat.groups.pinned",
"chat.groups.projects",
"chat.groups.today",
"chat.groups.yesterday",
"chat.groups.earlier",
"chat.groups.archived",
"thread.promptNavigator.railAria",
"thread.composer.mentions.cliTitle",
"thread.composer.mentions.mcpTitle",
"message.openLink",
"message.openAttachment",
"message.skill",
"settings.channels.connectionChecks",
"settings.channels.open",
];
const ACCIDENTALLY_SPANISH_SETTINGS_KEYS = [
"settings.help.provider",
"settings.help.configPath",
"settings.help.selectedPreset",
"settings.help.maxResults",
"settings.help.timeout",
"settings.help.jinaReader",
"settings.help.imageGeneration",
"settings.help.imageProvider",
"settings.help.imageProviderStatus",
"settings.help.imageModel",
"settings.help.defaultAspectRatio",
"settings.help.timezone",
"settings.help.securityManagedControls",
"settings.help.selectedModelProvider",
"settings.help.selectedModelValue",
"settings.help.cliAppsCatalog",
"settings.help.cliAppsFilter",
"settings.help.logs",
"settings.help.diagnostics",
"settings.help.localServiceAccessNative",
"settings.help.webuiDefaultAccessNative",
"settings.status.savedRestart",
"settings.status.restartAfterSaving",
"settings.status.savedRestartApply",
"settings.status.imageProviderRestart",
"settings.status.hostRestartAfterSaving",
"settings.status.hostRestartPending",
"settings.status.hostApiUnavailable",
"settings.status.logsOpened",
"settings.status.logsOpenFailed",
"settings.status.diagnosticsExported",
"settings.status.diagnosticsExportFailed",
"settings.image.missingCredential",
"settings.oauth.signInHelp",
];
const INDEX_HTML = readFileSync(resolve(process.cwd(), "index.html"), "utf8");
const PREBOOT_SCRIPT = INDEX_HTML.match(
/<script>\s*(\(function \(\) \{\s*var localeKey = "nanobot\.locale";[\s\S]*?\}\)\(\);)\s*<\/script>/,
@@ -479,6 +545,7 @@ describe("webui i18n", () => {
...LOCALIZED_SETTINGS_COPY_KEYS,
...LOCALIZED_WORKSPACE_COPY_KEYS,
...LOCALIZED_CHANNEL_SHELL_KEYS,
...LOCALIZED_NEW_SURFACE_KEYS,
].filter(
(key) => current.get(key) === english.get(key),
);
@@ -490,10 +557,10 @@ describe("webui i18n", () => {
it("keeps Simplified Chinese settings overview copy localized", () => {
const settings = resources["zh-CN"].common.settings;
expect(settings.nav.browser).toBe("网");
expect(settings.sections.webSearch).toBe("网搜索");
expect(settings.byok.tabs.webSearch).toBe("网搜索");
expect(settings.overview.webSearch).toBe("网搜索");
expect(settings.nav.browser).toBe("网");
expect(settings.sections.webSearch).toBe("网搜索");
expect(settings.byok.tabs.webSearch).toBe("网搜索");
expect(settings.overview.webSearch).toBe("网搜索");
expect(settings.overview.workspace).toBe("工作区");
expect(settings.skills.installedTab).toBe("已安装");
expect(settings.skills.discoverTab).toBe("发现");
@@ -503,6 +570,18 @@ describe("webui i18n", () => {
expect(settings.skills.marketplaceTrendingTitle).toBe("各市场热门技能");
});
it("keeps Indonesian and Vietnamese settings free of copied Spanish help text", () => {
const spanish = flattenResource(resources.es.common);
for (const locale of ["id", "vi"] as const) {
const current = flattenResource(resources[locale].common);
const copied = ACCIDENTALLY_SPANISH_SETTINGS_KEYS.filter(
(key) => current.get(key) === spanish.get(key),
);
expect({ locale, copied }).toEqual({ locale, copied: [] });
}
});
it("keeps Brazilian Portuguese settings overview copy localized", () => {
const settings = resources["pt-BR"].common.settings;
const sidebar = resources["pt-BR"].common.sidebar;
@@ -514,6 +593,6 @@ describe("webui i18n", () => {
expect(settings.sections.webSearch).toBe("Busca na web");
expect(settings.byok.tabs.webSearch).toBe("Busca na web");
expect(settings.overview.webSearch).toBe("Busca na web");
expect(settings.overview.workspace).toBe("Workspace");
expect(settings.overview.workspace).toBe("Espaço de trabalho");
});
});