#!/usr/bin/env node /** * Audit i18n coverage across module UI files. * * Background: @mana/shared-i18n + svelte-i18n are fully wired. Per-module * translation files exist under `apps/mana/apps/web/src/lib/i18n/locales/ * {module}/{de,en,it,fr,es}.json` for ~35 modules. Yet most module * `.svelte` templates hardcode German strings instead of calling `$_()`. * * This audit flags the gap without being a blocker: it prints a per-module * report of `.svelte` files that likely contain hardcoded German UI * strings AND don't yet import from `svelte-i18n` / `$_`. The stats guide * migration priorities without forcing a failing check. * * Detection heuristic: look for common German UI keywords inside Svelte * template text nodes (Abbrechen, Speichern, Löschen, Hinzufügen, * Erstellen, Bearbeiten, etc.). Not foolproof — can miss embedded * placeholder text and hit false positives — but good enough to prioritise. * * Usage: * node scripts/audit-i18n-coverage.mjs # full report * node scripts/audit-i18n-coverage.mjs --summary # one-line per module * node scripts/audit-i18n-coverage.mjs --top 10 # top N offenders only */ import { readFileSync, readdirSync, existsSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { dirname, join } from 'node:path'; const __dirname = dirname(fileURLToPath(import.meta.url)); const REPO_ROOT = join(__dirname, '..'); const MODULES_DIR = join(REPO_ROOT, 'apps/mana/apps/web/src/lib/modules'); const LOCALES_DIR = join(REPO_ROOT, 'apps/mana/apps/web/src/lib/i18n/locales'); const args = process.argv.slice(2); const SUMMARY = args.includes('--summary'); const TOP_IDX = args.indexOf('--top'); const TOP_N = TOP_IDX >= 0 ? Number(args[TOP_IDX + 1] || 10) : null; // Common German UI keywords that indicate hardcoded strings. Not every hit // is a real violation (e.g. code comments, type names) — we scan only // Svelte template bodies (between