fix: update i18n script to handle missing terms and write to target locales

This commit is contained in:
troyeguo committed 2026-09-27 09:39:39 +08:00
1 parent b2eec07ddc
commit 3a3fd2a88b
1 file changed
+10 -5
+10 -5
View File
@@ -9,6 +9,12 @@ for (let index = 0; index < folders.length; index++) {
resources.push(`../src/assets/locales/${folder}`);
}
console.info(resources);
let targets = [];
for (let index = 0; index < folders.length; index++) {
const folder = folders[index];
targets.push(`../scripts/locales/${folder}`);
}
console.info(targets);
// find the missing terms in the english
const zhdataRaw = fs.readFileSync(
@@ -62,12 +68,11 @@ for (let index = 0; index < resources.length; index++) {
missingTerms[term] = referData[term];
}
}
// console.info(missingTerms);
const mergedObj = Object.assign({}, targetData, missingTerms);
console.info(missingTerms);
const target = targets[index];
fs.writeFileSync(
path.join(__dirname, resource),
JSON.stringify(mergedObj, null, 2)
path.join(__dirname, target),
JSON.stringify(missingTerms, null, 2)
);
} catch (error) {
console.error("Error reading JSON file:", error);