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: directories:
- node_modules - node_modules
notifications: notifications:
slack: slack: $SLACK_NOTIFICATION_TOKEN
on_success: never
on_failure: $SLACK_NOTIFICATION_TOKEN
jobs: jobs:
include: include:
- stage: update translations - stage: update translations

View file

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