feat(i18n): localize panel shell

This commit is contained in:
youzini
2026-06-05 10:45:19 +00:00
parent 49860983a2
commit e06a3ca250
6 changed files with 485 additions and 153 deletions

View File

@@ -1,4 +1,5 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import zhCN from "../i18n/zh-CN.js";
import enUS from "../i18n/en-US.js";
@@ -44,4 +45,19 @@ assert.ok(
"catalog should include at least one interpolated string",
);
const panelHtml = readFileSync(new URL("../ui/panel.html", import.meta.url), "utf8");
const htmlKeys = new Set();
const attrRe = /data-i18n(?:-[a-z-]+)?="([^"]+)"/g;
let match;
while ((match = attrRe.exec(panelHtml))) {
htmlKeys.add(match[1]);
}
assert.ok(htmlKeys.size > 0, "panel.html should contain data-i18n references after Phase 1");
const missingHtmlKeys = [...htmlKeys].filter((key) => !Object.prototype.hasOwnProperty.call(zhCN, key));
assert.deepEqual(
missingHtmlKeys,
[],
`panel.html references missing i18n keys: ${missingHtmlKeys.join(", ")}`,
);
console.log("i18n catalog tests passed");