dika/scripts/check-i18n.js
2026-11-16 13:51:22 +05:00

12 lines
885 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import fs from "node:fs";
const keys = (l) => Object.keys(JSON.parse(fs.readFileSync(`public/i18n/${l}.json`, "utf8"))).sort().join();
const ru = keys("ru");
for (const l of ["kk", "en"]) if (keys(l) !== ru) { console.error(`i18n: ключи ${l} не совпадают с ru`); process.exit(1); }
console.log("i18n ok");
// Каждая акция из базы должна быть переведена на kk и en, иначе на экране смесь языков.
const csv = fs.readFileSync("data/venues.csv", "utf8").split(/\r?\n/).slice(1).filter(Boolean).map((r) => r.split(";")[11]);
for (const l of ["kk", "en"]) {
const map = JSON.parse(fs.readFileSync(`public/i18n/${l}.json`, "utf8")).promoTexts || {};
for (const p of csv) if (p && p !== "нет" && !map[p]) { console.error(`i18n: акция «${p}» не переведена (${l})`); process.exit(1); }
}