Files
neon-bar86.ru/site/scripts/rusify-stoplist-warning.mjs
T
2026-10-11 22:24:54 +05:00

58 lines
2.1 KiB
JavaScript

// Русификация блока STOP_LIST_WARNING в mixEngine (первый патч записал
// его с английским текстом). Только строки, счётчики проверяются.
import { readFileSync, writeFileSync, copyFileSync, existsSync } from "node:fs";
const F = "src/lib/mixEngine.ts";
let s = readFileSync(F, "utf8");
if (!existsSync(F + ".bak2")) copyFileSync(F, F + ".bak2");
const rep = (from, to, label) => {
const parts = s.split(from);
if (parts.length - 1 !== 1) die(`${label}: found ${parts.length - 1}, expected 1`);
s = parts.join(to);
console.log(label + "=ok");
};
function die(msg) {
console.error("RUS_FAIL: " + msg);
process.exit(1);
}
rep(
"/* ---------------- CRM stop-list: warnings in results ------------------- */",
"/* ------------------- Стоп-лист CRM: предупреждения в выдаче ---------------- */",
"section-comment",
);
rep(
"/** Warning on a mix card whose tobacco has gone into the CRM stop-list. */",
"/** Предупреждение на карточке микса, чей табак ушёл в стоп-лист CRM. */",
"const-comment",
);
rep(
" * Marks mixes whose composition contains a stopped tobacco (matching by",
" * Помечает миксы, в составе которых есть табак из стоп-листа CRM",
"jsdoc-1",
);
rep(
" * the engine flavor's catalogId). If there is nothing to change, returns",
" * (сверка по catalogId вкуса движка). Если менять нечего, возвращает",
"jsdoc-2",
);
rep(
" * the same references — safe to call on every stop-list poll.",
" * те же ссылки — безопасно вызывать на каждом опросе стоп-листа.",
"jsdoc-3",
);
rep(
'"Some tobaccos in the composition are in the stop-list — the hookah lounge attendant will pick a replacement.";',
'"В составе есть табак из стоп-листа — кальянщик подберёт замену.";',
"warning-text",
);
writeFileSync(F, s);
console.log("RUS_OK");