From 3a3fd2a88b7b60cd663a2963aa5e58a35435da9a Mon Sep 17 00:00:00 2001 From: troyeguo <13820674+troyeguo@users.noreply.github.com> Date: Sun, 27 Sep 2026 09:39:39 +0800 Subject: [PATCH] fix: update i18n script to handle missing terms and write to target locales --- scripts/i18n-script.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/i18n-script.js b/scripts/i18n-script.js index c7ce4581..ecd66cc9 100644 --- a/scripts/i18n-script.js +++ b/scripts/i18n-script.js @@ -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);