-
-
Notifications
You must be signed in to change notification settings - Fork 35.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tools): Script to delete all translations of a language on Crowd…
…in (#41380)
- Loading branch information
1 parent
55dfa28
commit 48981bf
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
tools/crowdin/one-off-scripts/delete-all-translations-for-a-language.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
This one-off script can be used to delete all existing translations for a specified language on Crowdin. | ||
Specifying a projectId and lanaguageId in the .env file allows the script to accomplish this task. | ||
*/ | ||
|
||
require('dotenv').config({ path: `${__dirname}/../.env` }); | ||
|
||
const { | ||
getLanguageTranslations, | ||
deleteLanguageTranslations | ||
} = require('../utils/strings'); | ||
|
||
const projectId = process.env.CROWDIN_PROJECT_ID; | ||
const languageId = process.env.CROWDIN_LANGUAGE_ID; | ||
|
||
(async (projectId, languageId) => { | ||
console.log('starting script...'); | ||
const translations = await getLanguageTranslations({ | ||
projectId, | ||
languageId | ||
}); | ||
if (translations && translations.length) { | ||
for (let translation of translations) { | ||
const { stringId } = translation.data; | ||
await deleteLanguageTranslations(projectId, languageId, stringId); | ||
} | ||
} | ||
console.log('complete'); | ||
})(projectId, languageId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CROWDIN_PROJECT_ID= | ||
CROWDIN_PERSONAL_TOKEN= | ||
CROWDIN_API_URL='https://freecodecamp.crowdin.com/api/v2/' | ||
CROWDIN_LANGUAGE_ID= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters