Helpers for failing validations

* Update Slack notification to always notify.
* Add optional parameter to `tx-pull-www` to pull just resources for a particular language. Helpful when validations are failing for one language.
This commit is contained in:
chrisgarrity 2019-03-21 11:00:12 +01:00
parent 341e3ae8b0
commit a995aa5413
2 changed files with 11 additions and 6 deletions

View file

@ -6,9 +6,7 @@ cache:
directories:
- node_modules
notifications:
slack:
on_success: never
on_failure: $SLACK_NOTIFICATION_TOKEN
slack: $SLACK_NOTIFICATION_TOKEN
jobs:
include:
- stage: update translations

View file

@ -14,9 +14,10 @@ const usage = `
Pull supported language translations from Transifex for the 'scratch-website' project.
It will query transifex for the list of resources.
Usage:
node tx-pull-www.js path
node tx-pull-www.js path [lang]
path: root for the translated resources.
Each resource will be a subdirectory containing language json files.
lang: optional language code - will only pull resources for that language
NOTE: 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.
`;
@ -39,6 +40,8 @@ const OUTPUT_DIR = path.resolve(args[0]);
// const MODE = {mode: 'reviewed'}; // default is everything for www
const CONCURRENCY_LIMIT = 4;
const lang = args.length === 2 ? args[1] : '';
const TX = new transifex({
project_slug: PROJECT,
credential: 'api:' + process.env.TX_TOKEN
@ -73,10 +76,14 @@ const getLocaleData = (item, callback) => {
const expandResourceFiles = (resources) => {
let items = [];
for (let resource of resources) {
if (lang) {
items.push({resource: resource.slug, locale: lang});
} else {
for (let locale of Object.keys(locales)) {
items.push({resource: resource.slug, locale: locale});
}
}
}
return items;
};