Files
yourpart3/frontend/scripts/merge-ceb-locale-patch.mjs
Torsten Schulz (local) f715c6125d
All checks were successful
Deploy to production / deploy (push) Successful in 2m48s
feat(i18n): implement deep merging for locale chunks and enhance Cebuano translations
- Introduced a deep merge function to combine locale chunks, improving the handling of language data for Cebuano.
- Updated Cebuano locale files with comprehensive translations, including new sections for admin, social network, and settings.
- Enhanced existing translations for clarity and consistency across various components, ensuring a better user experience.
- Added new fields in the settings and profile sections to capture more user attributes, improving personalization options.
2026-04-07 16:23:11 +02:00

46 lines
1.5 KiB
JavaScript

#!/usr/bin/env node
/**
* Tiefes Zusammenführen eines Patch-Objekts in eine Ceb-Locale-Datei.
* Nutzung: node merge-ceb-locale-patch.mjs <ziel.json> <patch.json>
*/
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
function isPlainObject(value) {
return value !== null && typeof value === 'object' && !Array.isArray(value);
}
function deepMerge(target, source) {
if (!isPlainObject(source)) return target;
const base = isPlainObject(target) ? { ...target } : {};
for (const key of Object.keys(source)) {
const sv = source[key];
const tv = base[key];
if (isPlainObject(sv) && isPlainObject(tv)) {
base[key] = deepMerge(tv, sv);
} else if (isPlainObject(sv)) {
base[key] = deepMerge({}, sv);
} else {
base[key] = sv;
}
}
return base;
}
const targetPath = path.resolve(process.argv[2] || '');
const patchPath = path.resolve(process.argv[3] || '');
if (!targetPath || !patchPath || !fs.existsSync(targetPath) || !fs.existsSync(patchPath)) {
console.error('Usage: node merge-ceb-locale-patch.mjs <target.json> <patch.json>');
process.exit(1);
}
const base = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
const patch = JSON.parse(fs.readFileSync(patchPath, 'utf8'));
const merged = deepMerge(base, patch);
fs.writeFileSync(targetPath, JSON.stringify(merged, null, 4) + '\n', 'utf8');
console.log('Merged patch into', targetPath);