game1 / client / test / i18n.test.mjs
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Catalog completeness — the CLJS replacement for the TS-era MsgKey type
// check: every EN key must exist in ro/hu (a missing translation fails the
// suite), no stray keys, and the plural shapes carry the documented variants.
import test from "node:test";
import assert from "node:assert/strict";
import * as lib from "../test-dist/testlib.js";

const en = [...lib.catalogKeys("en")];

test("EN catalog is non-empty and carries the social.* block", () => {
  assert.ok(en.length >= 40);
  assert.ok(en.some((k) => k.startsWith("social.")));
});

for (const lang of ["ro", "hu"]) {
  test(`${lang} covers every EN key, and nothing else`, () => {
    assert.deepEqual([...lib.catalogKeys(lang)], en);
  });
}

test("plural sites: ro one/few/other, hu other-only, en one/other", () => {
  assert.deepEqual([...lib.catalogMsg("en", "status.linked")], ["one", "other"]);
  assert.deepEqual([...lib.catalogMsg("ro", "status.linked")], ["few", "one", "other"]);
  assert.deepEqual([...lib.catalogMsg("hu", "status.linked")], ["other"]);
});

test("wire-adjacent strings are never translated (brand + protocol)", () => {
  // tap zones and brand names may translate; message KEYS must be identical —
  // covered above — and no catalog value may contain the protocol prefix.
  for (const lang of ["en", "ro", "hu"]) {
    for (const k of lib.catalogKeys(lang)) {
      const m = lib.catalogMsg(lang, k);
      if (typeof m === "string") assert.ok(!m.includes("/neon-grid/"), `${lang} ${k}`);
    }
  }
});

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/game1.git