mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-14 16:07:52 +00:00
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.
This commit is contained in:
@@ -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<string>();
|
||||
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("");
|
||||
|
||||
@@ -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`",
|
||||
|
||||
Reference in New Issue
Block a user