-
-
Notifications
You must be signed in to change notification settings - Fork 186
/
clean-terms.js
24 lines (19 loc) · 991 Bytes
/
clean-terms.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { getTerms, deleteTerms } = require('./poeditor');
async function main(project_id, api_token) {
const enTranslationFile = './src/i18n/locales/en.json';
const enTranslations = require(enTranslationFile);
const terms = await getTerms(project_id, api_token, 'en');
const cleanableContexts = [
'"featureDescriptions"',
'"featureNames"',
'"settingsSchemaDescriptions"',
'"settingsSchemaTitles"',
];
const cleanableTerms = terms.filter((term) => cleanableContexts.includes(term.context));
const termsToClean = cleanableTerms.filter((term) => !enTranslations[JSON.parse(term.context)][term.term]);
console.log(`cleanableTerms ${cleanableTerms.length}, termsToClean ${termsToClean.length}`);
const deletionResults = await deleteTerms(project_id, api_token, termsToClean);
console.log(deletionResults);
}
const { POEDITOR_PROJECT_ID, POEDITOR_API_TOKEN } = process.env;
main(POEDITOR_PROJECT_ID, POEDITOR_API_TOKEN);