mirror of
https://github.com/scratchfoundation/scratch-l10n.git
synced 2024-12-25 07:02:30 -05:00
30b1975e94
* Fixed a bug in the push script (tags were not saved as correct structured json, so they weren’t getting put into transifex) * extended FreshDesk API with functions to update knowledge base. Functions automatically try to create the item if it isn’t found for updating * tx-pull-help-names: pulls category and folder name translations from transifex and updates them in Freshdesk (Note, since we don’t send people into the knowledge base, these aren’t really public, but the actual folders and categories have to exist to be able to save articles) * tx-pull-help-articles: pull article translations from Transifex and update the Freshdesk KB. * help-utils: utility functions for the tx-pull-help-* scripts. Handles limiting the number of things happening in parallel - currently two languages may be processed at the same time.
35 lines
1.2 KiB
JavaScript
Executable file
35 lines
1.2 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
/**
|
|
* @fileoverview
|
|
* Script to pull scratch-help translations from transifex and push to FreshDesk.
|
|
*/
|
|
|
|
const args = process.argv.slice(2);
|
|
|
|
const usage = `
|
|
Pull knowledge base category and folder names from transifex and push to FreshDesk. Usage:
|
|
node tx-pull-help.js
|
|
NOTE:
|
|
FRESHDESK_TOKEN environment variable needs to be set to a FreshDesk API key with
|
|
access to the Knowledge Base.
|
|
TX_TOKEN environment variable needs to be set with a Transifex API token. See
|
|
the Localization page on the GUI wiki for information about setting up Transifex.
|
|
`;
|
|
// Fail immediately if the API tokens are not defined, or there any argument
|
|
if (!process.env.TX_TOKEN || !process.env.FRESHDESK_TOKEN || args.length > 0) {
|
|
process.stdout.write(usage);
|
|
process.exit(1);
|
|
}
|
|
|
|
const {getInputs, saveItem, localizeNames} = require('./help-utils.js');
|
|
|
|
getInputs()
|
|
.then(([languages, folders, names]) => { // eslint-disable-line no-unused-vars
|
|
process.stdout.write('Process Category and Folder Names pulled from Transifex\n');
|
|
return names.map(item => saveItem(item, languages, localizeNames));
|
|
})
|
|
.catch((e) => {
|
|
process.stdout.write(`Error: ${e.message}\n`);
|
|
process.exitCode = 1; // not ok
|
|
});
|