Skip to content

Commit

Permalink
update lang sync - remove old translations (#1751)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Nov 19, 2023
1 parent c2dd4ad commit c2f0d59
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scripts/lang-sync.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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
Expand Down

0 comments on commit c2f0d59

Please sign in to comment.