Add manually authored Simplified Chinese viewer and tutorial catalog

This commit is contained in:
coyotte508 2026-10-20 14:13:13 +02:00
commit a64194deb6
5 changed files with 1335 additions and 3 deletions

View file

@ -11,6 +11,7 @@ export const languages = {
"pt-BR": "Português (Brasil)", "pt-BR": "Português (Brasil)",
ko: "한국어", ko: "한국어",
"zh-TW": "繁體中文", "zh-TW": "繁體中文",
"zh-CN": "简体中文",
vi: "Tiếng Việt", vi: "Tiếng Việt",
it: "Italiano", it: "Italiano",
nl: "Nederlands", nl: "Nederlands",
@ -32,6 +33,7 @@ export function resolveLocale(value) {
if (/^zh-(?:tw|hk|mo|hant)(?:-|$)/.test(tag)) { if (/^zh-(?:tw|hk|mo|hant)(?:-|$)/.test(tag)) {
return "zh-TW"; return "zh-TW";
} }
if (/^zh(?:-|$)/.test(tag)) return "zh-CN";
return Object.keys(languages).find((locale) => locale === tag.split("-")[0]) ?? "en"; return Object.keys(languages).find((locale) => locale === tag.split("-")[0]) ?? "en";
} }

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,25 @@ if (!directory) {
} }
const source = JSON.parse(await readFile(join(directory, "en.json"), "utf8")); const source = JSON.parse(await readFile(join(directory, "en.json"), "utf8"));
const placeholders = (text) => [...text.matchAll(/\{\w+\}/g)].map((match) => match[0]).sort(); const placeholders = (text) => [...text.matchAll(/\{\w+\}/g)].map((match) => match[0]).sort();
const locales = ["en", "de", "fr", "pl", "ro", "el", "hi", "ru", "da", "pt-BR", "ko", "zh-TW", "vi", "it", "nl", "fa"]; const locales = [
"en",
"de",
"fr",
"pl",
"ro",
"el",
"hi",
"ru",
"da",
"pt-BR",
"ko",
"zh-TW",
"zh-CN",
"vi",
"it",
"nl",
"fa",
];
for (const locale of locales) { for (const locale of locales) {
const catalog = JSON.parse(await readFile(join(directory, `${locale}.json`), "utf8")); const catalog = JSON.parse(await readFile(join(directory, `${locale}.json`), "utf8"));
assert.deepEqual(Object.keys(catalog).sort(), Object.keys(source).sort(), `${locale}: missing or extra strings`); assert.deepEqual(Object.keys(catalog).sort(), Object.keys(source).sort(), `${locale}: missing or extra strings`);

View file

@ -24,7 +24,11 @@ test("regional language preferences select supported catalogues", () => {
assert.equal(resolveLocale("nl-BE"), "nl"); assert.equal(resolveLocale("nl-BE"), "nl");
assert.equal(resolveLocale("pt-PT"), "pt-BR"); assert.equal(resolveLocale("pt-PT"), "pt-BR");
assert.equal(resolveLocale("zh-Hant-TW"), "zh-TW"); assert.equal(resolveLocale("zh-Hant-TW"), "zh-TW");
assert.equal(resolveLocale("zh-CN"), "en"); assert.equal(resolveLocale("zh-CN"), "zh-CN");
assert.equal(resolveLocale("zh"), "zh-CN");
assert.equal(resolveLocale("ZH_hans_SG"), "zh-CN");
assert.equal(resolveLocale("zh-SG"), "zh-CN");
assert.equal(resolveLocale("zh-HK"), "zh-TW");
assert.equal(resolveLocale(undefined), "en"); assert.equal(resolveLocale(undefined), "en");
}); });
test("dynamic values are reordered while player names stay unchanged", () => { test("dynamic values are reordered while player names stay unchanged", () => {

View file

@ -16,7 +16,23 @@ const server = createServer(async (req, res) => {
await new Promise((r) => server.listen(0, "127.0.0.1", r)); await new Promise((r) => server.listen(0, "127.0.0.1", r));
const browser = await chromium.launch({ headless: true, executablePath: process.env.FUJI_CHROMIUM_EXECUTABLE }); const browser = await chromium.launch({ headless: true, executablePath: process.env.FUJI_CHROMIUM_EXECUTABLE });
try { try {
for (const locale of ["fr", "de", "nl", "da", "it", "ro", "pt-BR", "pl", "ru", "el", "hi", "ko", "zh-TW", "vi"]) { for (const locale of [
"fr",
"de",
"nl",
"da",
"it",
"ro",
"pt-BR",
"pl",
"ru",
"el",
"hi",
"ko",
"zh-TW",
"zh-CN",
"vi",
]) {
const page = await browser.newPage({ viewport: { width: 390, height: 844 } }); const page = await browser.newPage({ viewport: { width: 390, height: 844 } });
const errors = []; const errors = [];
page.on("pageerror", (e) => errors.push(e.message)); page.on("pageerror", (e) => errors.push(e.message));