From 24deeb0dbb69b9d807295492f58139c8dddee91c Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Wed, 11 Nov 2026 22:58:21 +0800 Subject: [PATCH] fix(i18n): drop repeated zh catalog keys and test that every key appears once (#2752) Merges had added eleven zh.json keys a second time (Docker, Shell, the language names, Add Service ({kind}), Others, Servers). JSON.parse silently keeps the last copy, so nothing failed. The catalogs test now reads each catalog file and fails on a key listed twice. --- src/platform/i18n.test.ts | 14 ++++++++++++++ src/platform/locales/text/zh.json | 11 ----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/platform/i18n.test.ts b/src/platform/i18n.test.ts index 883311117..28ec01930 100644 --- a/src/platform/i18n.test.ts +++ b/src/platform/i18n.test.ts @@ -296,6 +296,20 @@ describe("catalogs", () => { expect(Object.keys(texts).sort()).toEqual([...SUPPORTED_LOCALES].sort()); }); + it("list every key once", () => { + // JSON.parse keeps the last of two equal keys, so a merge that adds a key twice goes unnoticed. + for (const dir of [LOCALES_DIR, join(LOCALES_DIR, "text")]) { + for (const file of readdirSync(dir).filter((f) => f.endsWith(".json"))) { + const keys = [...readFileSync(join(dir, file), "utf8").matchAll(/^ {2}("(?:[^"\\]|\\.)*"):/gm)].map( + (m) => JSON.parse(m[1]!) as string, + ); + const seen = new Set(); + const repeated = keys.filter((key) => seen.has(key) || !seen.add(key)); + expect(repeated, `${file} in ${dir}`).toEqual([]); + } + } + }); + it("translate source text into non-empty text", () => { for (const [locale, catalog] of Object.entries(texts)) for (const [source, text] of Object.entries(catalog)) expect(text.trim(), `${locale}:${source}`).not.toBe(""); diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index 08ff216b1..82afb5b86 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -7120,17 +7120,6 @@ "No build": "不构建", "Build, no error check": "构建,不检查错误", "Before launch build for this Java configuration": "此 Java 配置启动前的构建方式", - "Docker": "Docker", - "Shell": "Shell", - "C/C++": "C/C++", - "Go": "Go", - "Rust": "Rust", - "Python": "Python", - "JavaScript": "JavaScript", - "Java": "Java", - "Add Service ({kind})": "添加服务({kind})", - "Others": "其他", - "Servers": "服务器", "Open main menu with a lone Alt press": "单独按下 Alt 打开主菜单", "When off, Alt key combinations still work but pressing Alt alone does not focus the main menu": "关闭后,Alt 组合键仍然可用,但单独按下 Alt 不会聚焦主菜单", "the bundle of {gemfile} has no `debug` gem. Add `gem \"debug\"` to the Gemfile and run `bundle install`": "{gemfile} 的 bundle 中没有 `debug` gem。请在 Gemfile 中添加 `gem \"debug\"`,然后运行 `bundle install`",