From c2f0d591d14030726e7694a4f6bb72ed274259ba Mon Sep 17 00:00:00 2001 From: Ben <43026681+bwp91@users.noreply.github.com> Date: Sun, 19 Nov 2023 22:56:25 +0000 Subject: [PATCH] update lang sync - remove old translations (#1751) --- scripts/lang-sync.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/lang-sync.ts b/scripts/lang-sync.ts index 30ce49206..3e1c97a2e 100644 --- a/scripts/lang-sync.ts +++ b/scripts/lang-sync.ts @@ -1,6 +1,7 @@ - /** - * Script to copy new english translation strings to the other language files + * Script to: + * - copy new english translation strings to the other language files + * - remove old translation strings from the other language files */ import * as fs from 'fs-extra'; @@ -18,11 +19,19 @@ for (const lang of langFiles) { const translationStrings = fs.readJsonSync(langPath); if (lang !== 'en.json') { + // find any keys in the main file that are not in the translation file, and add for (const [key, value] of Object.entries(main)) { if (!translationStrings.hasOwnProperty(key)) { translationStrings[key] = value; } } + + // find any keys in the translation file that are not in the main file, and remove + for (const key of Object.keys(translationStrings)) { + if (!main.hasOwnProperty(key)) { + delete translationStrings[key]; + } + } } // sort keys