All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 45s
- Implemented `fill-de-extended-gaps.js` to fill missing billing/orders keys in de-extended from de. - Created `fill-i18n-deep.py` for deep translation of locale JSONs using deep-translator with fallback options. - Added `fill-i18n-locales.js` to translate locale JSONs and write overrides for untranslated keys. - Introduced `fix-en-leaks.py` to translate keys that still match the en-US merge, addressing English leaks. - Developed `patch-de-ch-swiss.js` to replace 'ß' with 'ss' in de-CH.json without deleting existing entries. - Created `patch-en-gb-au.js` to apply UK/AU spelling corrections in en-GB and en-AU locales. - Added shell scripts `run-fix-en-leaks.sh` and `run-i18n-deep-fill.sh` for sequential execution of translation tasks. - Implemented `update-i18n-todo-stats.js` to update statistics in the I18N_TODO.md file based on translation completeness.
48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
/** UK/AU-Orthografie in en-GB / en-AU (gegenüber en-US). */
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const LOCALES_DIR = path.join(__dirname, '../frontend/src/i18n/locales');
|
|
|
|
const UK_MAP = [
|
|
[/\bcolor\b/gi, (m) => (m[0] === 'C' ? 'Colour' : 'colour')],
|
|
[/\bcolors\b/gi, (m) => (m[0] === 'C' ? 'Colours' : 'colours')],
|
|
[/\borganize\b/gi, (m) => (m[0] === 'O' ? 'Organise' : 'organise')],
|
|
[/\borganized\b/gi, (m) => (m[0] === 'O' ? 'Organised' : 'organised')],
|
|
[/\bcenter\b/gi, (m) => (m[0] === 'C' ? 'Centre' : 'centre')],
|
|
[/\bfavorite\b/gi, (m) => (m[0] === 'F' ? 'Favourite' : 'favourite')],
|
|
[/\bfavorites\b/gi, (m) => (m[0] === 'F' ? 'Favourites' : 'favourites')],
|
|
[/\blabor\b/gi, (m) => (m[0] === 'L' ? 'Labour' : 'labour')],
|
|
[/\bdefense\b/gi, (m) => (m[0] === 'D' ? 'Defence' : 'defence')],
|
|
];
|
|
|
|
function applyUk(text) {
|
|
let out = text;
|
|
for (const [re, repl] of UK_MAP) {
|
|
out = out.replace(re, repl);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
function walk(obj, fn) {
|
|
if (!obj || typeof obj !== 'object' || Array.isArray(obj)) return;
|
|
for (const [key, value] of Object.entries(obj)) {
|
|
if (typeof value === 'string') obj[key] = fn(value);
|
|
else if (value && typeof value === 'object') walk(value, fn);
|
|
}
|
|
}
|
|
|
|
for (const locale of ['en-GB', 'en-AU']) {
|
|
const p = path.join(LOCALES_DIR, `${locale}.json`);
|
|
const data = JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
let n = 0;
|
|
walk(data, (s) => {
|
|
const t = applyUk(s);
|
|
if (t !== s) n++;
|
|
return t;
|
|
});
|
|
fs.writeFileSync(p, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
|
|
console.log(`${locale}: ${n} UK spelling patches`);
|
|
}
|