mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-06-14 02:40:45 +08:00
feat(i18n): localize panel shell
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user