mirror of
https://github.com/koodo-reader/koodo-reader.git
synced 2026-04-21 15:29:48 -04:00
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const translatedDir = path.join(__dirname, "../translated");
|
|
const localesDir = path.join(__dirname, "../src/assets", "locales");
|
|
|
|
const files = fs.readdirSync(translatedDir).filter((f) => f.endsWith(".json"));
|
|
|
|
let totalMerged = 0;
|
|
|
|
for (const file of files) {
|
|
const translatedPath = path.join(translatedDir, file);
|
|
const localesPath = path.join(localesDir, file);
|
|
|
|
if (!fs.existsSync(localesPath)) {
|
|
console.warn(`⚠️ Skipped: ${file} (not found in locales)`);
|
|
continue;
|
|
}
|
|
|
|
const translated = JSON.parse(fs.readFileSync(translatedPath, "utf-8"));
|
|
const locales = JSON.parse(fs.readFileSync(localesPath, "utf-8"));
|
|
|
|
const mergedCount = Object.keys(translated).length;
|
|
const merged = { ...locales, ...translated };
|
|
|
|
fs.writeFileSync(localesPath, JSON.stringify(merged, null, 2), "utf-8");
|
|
|
|
totalMerged += mergedCount;
|
|
console.info(`✅ ${file}: merged ${mergedCount} entries`);
|
|
}
|
|
|
|
console.info(`\nDone. Total entries merged: ${totalMerged}`);
|