taskgenius_taskgenius-plugin/scripts/compile-i18n.mjs
Quorafind f28ea8e9c0 refactor(v10): modularize entry + gantt year-view and project grouping fixes
Decompose the monolithic plugin entry into bootstrap modules and extracted
pure functions (src/bootstrap, src/modules), advance dataflow project
resolution, and reconcile the Phase 0 contract tests.

Fixes bundled in:
- gantt: fix year-zoom timeline so year/month labels render and a full year
  fits on screen. Major-label gate no longer keyed on single-day width; add
  a Year minor-label branch; formatMinorTick('Year') returns a real month
  name; lower MIN_DAY_WIDTH to 2; drop per-render logging; register the
  offscreen-indicator click handlers once to stop a listener leak.
- project: stop the Projects view fragmenting into one task per file.
  determineTgProject() gains an applyDefaultNaming option (default true,
  preserving the public API / File Source / unit tests); the dataflow cache
  and worker-sync paths pass false so they match ProjectData.worker.
- build: restore RegExpCursor in progress-bar-widget (the SearchCursor
  migration was incomplete -- SearchCursor cannot do regex search).

Pre-commit hook (npm run build) verified manually; hook could not spawn on
this Windows Git Bash setup. Tests: 1718 passing; production build green.
2026-06-28 16:09:40 +08:00

26 lines
855 B
JavaScript

#!/usr/bin/env node
import fs from "fs";
import path from "path";
const LOCALE_DIR = "src/translations/locale";
const OUT_DIR = "i18n";
fs.mkdirSync(OUT_DIR, { recursive: true });
for (const file of fs.readdirSync(LOCALE_DIR)) {
if (!file.endsWith(".ts")) continue;
const source = fs.readFileSync(path.join(LOCALE_DIR, file), "utf8");
const json = source
.replace(/^\s*\/\/.*$/gm, "")
.replace(/^\s*const\s+translations\s*=\s*/, "")
.replace(/;?\s*export\s+default\s+translations;?\s*$/, "");
const translations = Function(`return (${json});`)();
const outFile = path.join(OUT_DIR, file.replace(/\.ts$/, ".json"));
fs.writeFileSync(outFile, JSON.stringify(translations));
const sizeKB = (Buffer.byteLength(JSON.stringify(translations)) / 1024).toFixed(1);
console.log(` ${file} -> ${outFile} (${sizeKB} KB)`);
}
console.log("Done.");