Skip to content

Commit

Permalink
chore(linter): make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
nurikk committed Feb 11, 2024
1 parent d2ef1e6 commit ffafc98
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
9 changes: 3 additions & 6 deletions clean-terms.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { getTerms, deleteTerms } = require("./poeditor");
const { getTerms, deleteTerms } = require('./poeditor');

async function main(project_id, api_token) {
const enTranslationFile = './src/i18n/locales/en.json';
Expand All @@ -11,16 +11,13 @@ async function main(project_id, api_token) {
'"settingsSchemaDescriptions"',
'"settingsSchemaTitles"',
];
const cleanableTerms = terms
.filter((term) => cleanableContexts.includes(term.context));
const cleanableTerms = terms.filter((term) => cleanableContexts.includes(term.context));

const termsToClean = cleanableTerms
.filter((term) => !enTranslations[JSON.parse(term.context)][term.term]);
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;
Expand Down
1 change: 0 additions & 1 deletion i18n-z2m-exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ devices.forEach((device) => {
const enTranslationFile = './src/i18n/locales/en.json';
const enTranslations = require(enTranslationFile);


let settingsSchemaDescriptions = {};
let settingsSchemaTitles = {};
const isObject = (value) => value !== null && typeof value === 'object';
Expand Down
10 changes: 4 additions & 6 deletions poeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function downloadLanguage(project_id, api_token, language) {
async function getAvaliableLanguages(project_id, api_token) {
const languages = await callApi('https://api.poeditor.com/v2/languages/list', {
api_token,
id: project_id
id: project_id,
});
return languages.result.languages.map((lang) => ({ code: lang.code, name: lang.name }));
}
Expand All @@ -36,20 +36,18 @@ async function getTerms(project_id, api_token, language) {
const terms = await callApi('https://api.poeditor.com/v2/terms/list', {
api_token,
id: project_id,
language
language,
});
return terms.result.terms.map((term) => ({ term: term.term, context: term.context }));
}


async function deleteTerms(project_id, api_token, terms) {
const res = await callApi('https://api.poeditor.com/v2/terms/delete', {
api_token,
id: project_id,
data: JSON.stringify(terms)
data: JSON.stringify(terms),
});
return res;
}


module.exports = { downloadLanguage, getAvaliableLanguages, getTerms, deleteTerms };
module.exports = { downloadLanguage, getAvaliableLanguages, getTerms, deleteTerms };

0 comments on commit ffafc98

Please sign in to comment.