/** * Baut scripts/ceb-patches/falukant-patch.json aus /tmp/ceb-fal-miss.json (EN) mit Phrase-Mapping → Bisaya. */ import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const root = path.resolve(__dirname, '..'); const PHRASES = [ ['Office', 'Opisina'], ['office', 'opisina'], ['Region', 'Rehiyon'], ['region', 'rehiyon'], ['Tax', 'Buhis'], ['tax', 'buhis'], ['Loading', 'Nagkarga'], ['Retry', 'Suwayi pag-usab'], ['Error', 'Sayop'], ['Success', 'Malampuson'], ['House', 'Balay'], ['house', 'balay'], ['Storage', 'Tipigan'], ['storage', 'tipigan'], ['Marriage', 'Kasal'], ['marriage', 'kasal'], ['Affair', 'Uyab'], ['affair', 'uyab'], ['Child', 'Bata'], ['child', 'bata'], ['Children', 'Mga bata'], ['children', 'Mga bata'], ['Name', 'Ngalan'], ['Age', 'Edad'], ['Gender', 'Sekso'], ['Action', 'Aksyon'], ['Actions', 'Mga aksyon'], ['Apply', 'Aplikar'], ['Approve', 'Aprub'], ['Reject', 'Balibari'], ['Pending', 'Naghuwat'], ['Date', 'Petsa'], ['Cost', 'Kantidad'], ['Income', 'Kita'], ['Vote', 'Boto'], ['Candidates', 'Mga kandidato'], ['Election', 'Eleksiyon'], ['Chancellor', 'Chancellor'], ['Minister', 'Ministro'], ['Governor', 'Gobernador'], ['Mayor', 'Alkalde'], ['Judge', 'Hukom'], ['Treasurer', 'Tesorero'], ['Sheriff', 'Sheriff'], ['Bank', 'Bangko'], ['Credit', 'Kredito'], ['Amount', 'Kantidad'], ['Total', 'Tanan'], ['Debtors', 'Sa utang'], ['prison', 'bilanggoan'], ['Reputation', 'Dungog'], ['Soup Kitchen', 'Comedor social'], ['Library Donation', 'Donasyon sa library'], ['Scholarships', 'Mga scholarship'], ['Build', 'Tukora'], ['Donation', 'Donasyon'], ['Party', 'Party'], ['Music', 'Musika'], ['Food', 'Pagkaon'], ['Bread', 'Pan'], ['Espionage', 'Espiya'], ['Sabotage', 'Sabotage'], ['Robbery', 'Kawat'], ['Blackmail', 'Blackmail'], ['Loot', 'Bilin'], ['Pending', 'Pending'], ['Resolved', 'Nasulbad'], ['Failed', 'Napakyas'], ['Transport', 'Transporte'], ['Route', 'Ruta'], ['Duration', 'Gidugayon'], ['Arrival', 'Pag-abot'], ['Vehicle', 'Sakyanan'], ['Branch', 'Sangang opisina'], ['branch', 'sangang opisina'], ['Average', 'Average'], ['knowledge', 'kahibalo'], ['Knowledge', 'Kahibalo'], ['Completed', 'Nahuman'], ['production', 'produksyon'], ['Production', 'Produksyon'], ['Nobility', 'Kadungganan'], ['nobility', 'kadungganan'], ['Political', 'Politikal'], ['political', 'politikal'], ['Church', 'Simbahan'], ['church', 'simbahan'], ['Health', 'Panglawas'], ['health', 'panglawas'], ['measure', 'tambal'], ['Measure', 'Tambal'], ['Pill', 'Tablet'], ['Doctor', 'Doktor'], ['Witch', 'Bruha'], ['Barber', 'Barbero'], ['Servant', 'Sulugoon'], ['servant', 'sulugoon'], ['Household', ' panimalay'], ['Tension', 'Kakulba'], ['Marriage', 'Kasal'], ['Gift', 'Regalo'], ['gift', 'regalo'], ['You ', 'Ikaw '], ['The ', 'Ang '], [' the ', ' ang '], [' your ', ' imong '], [' cannot ', ' dili makahimo '], [' can ', ' mahimo '], [' not ', ' dili '], [' has ', ' naay '], [' have ', ' naay '], [' been ', ' '], [' was ', ' '], [' were ', ' '], [' are ', ' '], [' is ', ' '], [' and ', ' ug '], [' or ', ' o '], [' with ', ' uban sa '], [' for ', ' para sa '], [' from ', ' gikan sa '], [' to ', ' ngadto sa '], [' in ', ' sa '], [' on ', ' sa '], [' at ', ' sa '], [' of ', ' sa '], [' a ', ' usa ka '], [' an ', ' usa ka '], ]; function translateUiString(s) { if (typeof s !== 'string') return s; let out = s; for (const [en, ceb] of PHRASES) { if (out.includes(en)) out = out.split(en).join(ceb); } return out; } function mapStringsDeep(node) { if (typeof node === 'string') return translateUiString(node); if (node === null || typeof node !== 'object' || Array.isArray(node)) return node; const out = {}; for (const k of Object.keys(node)) { out[k] = mapStringsDeep(node[k]); } return out; } const missPath = '/tmp/ceb-fal-miss.json'; if (!fs.existsSync(missPath)) { console.error('Missing', missPath); process.exit(1); } const inner = mapStringsDeep(JSON.parse(fs.readFileSync(missPath, 'utf8'))); const patch = { falukant: inner }; const outPath = path.join(root, 'scripts', 'ceb-patches', 'falukant-patch.json'); fs.mkdirSync(path.dirname(outPath), { recursive: true }); fs.writeFileSync(outPath, JSON.stringify(patch, null, 2) + '\n', 'utf8'); console.log('Wrote', outPath);