mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 17:21:16 +08:00
- 实现了配置模式解析器,支持递归对象/数组/标量树结构 - 添加了可编辑字段收集功能,支持标量和数组类型的批量编辑 - 集成了YAML解析器,支持嵌套对象、数组和注释提取 - 实现了配置验证诊断,支持中英文本地化错误消息 - 添加了表单更新应用功能,支持安全的嵌套对象编辑 - 实现了示例配置生成功能,包含模式描述作为YAML注释 - 提供了批量数组值解析和枚举值标准化工具函数 - 集成了多语言支持,包含中英文验证消息本地化
37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const {createLocalizer} = require("../src/localization");
|
|
|
|
test("createLocalizer should default to English strings", () => {
|
|
const localizer = createLocalizer("en");
|
|
|
|
assert.equal(localizer.languageTag, "en");
|
|
assert.equal(localizer.isChinese, false);
|
|
assert.equal(localizer.t("webview.button.save"), "Save Form");
|
|
assert.equal(
|
|
localizer.t("message.batchEditUpdated", {count: 2, domain: "monster"}),
|
|
"Batch updated 2 config file(s) in 'monster'.");
|
|
});
|
|
|
|
test("createLocalizer should switch to Simplified Chinese for zh languages", () => {
|
|
const localizer = createLocalizer("zh-cn");
|
|
|
|
assert.equal(localizer.languageTag, "zh-CN");
|
|
assert.equal(localizer.isChinese, true);
|
|
assert.equal(localizer.t("webview.button.save"), "保存表单");
|
|
assert.equal(
|
|
localizer.t("message.batchEditUpdated", {count: 2, domain: "monster"}),
|
|
"已在“monster”中批量更新 2 个配置文件。");
|
|
});
|
|
|
|
test("createLocalizer should fall back to English for Traditional Chinese locales", () => {
|
|
const localizer = createLocalizer("zh-TW");
|
|
|
|
assert.equal(localizer.languageTag, "zh-tw");
|
|
assert.equal(localizer.isChinese, false);
|
|
assert.equal(localizer.t("webview.button.save"), "Save Form");
|
|
assert.equal(
|
|
localizer.t("message.batchEditUpdated", {count: 2, domain: "monster"}),
|
|
"Batch updated 2 config file(s) in 'monster'.");
|
|
});
|