26 lines
889 B
TypeScript
26 lines
889 B
TypeScript
import { readFileSync } from "node:fs";
|
|
import { describe, expect, it } from "vitest";
|
|
import { LOCALES } from "@/lib/locale";
|
|
|
|
// Neue Schlüssel in allen vier Sprachen (CLAUDE.md, Regel 1).
|
|
function keys(value: unknown, prefix = ""): string[] {
|
|
if (value && typeof value === "object") {
|
|
return Object.entries(value).flatMap(([k, v]) => keys(v, prefix ? `${prefix}.${k}` : k));
|
|
}
|
|
return [prefix];
|
|
}
|
|
|
|
const load = (l: string) => JSON.parse(readFileSync(`messages/${l}.json`, "utf8"));
|
|
|
|
describe("messages", () => {
|
|
const reference = keys(load("de")).sort();
|
|
for (const locale of LOCALES) {
|
|
it(`${locale} has the same keys as de`, () => {
|
|
expect(keys(load(locale)).sort()).toEqual(reference);
|
|
});
|
|
}
|
|
it("no emoji in UI texts", () => {
|
|
for (const locale of LOCALES) expect(JSON.stringify(load(locale))).not.toMatch(/\p{Extended_Pictographic}/u);
|
|
});
|
|
});
|