Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update lang sync - remove old translations #1751

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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