From a995aa541338274f4985c1983fb96b54765c9e0b Mon Sep 17 00:00:00 2001 From: chrisgarrity Date: Thu, 21 Mar 2019 11:00:12 +0100 Subject: [PATCH] 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. --- .travis.yml | 4 +--- scripts/tx-pull-www.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9cceee71..1c632574 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/scripts/tx-pull-www.js b/scripts/tx-pull-www.js index 1fda8911..45d292c7 100755 --- a/scripts/tx-pull-www.js +++ b/scripts/tx-pull-www.js @@ -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,8 +76,12 @@ const getLocaleData = (item, callback) => { const expandResourceFiles = (resources) => { let items = []; for (let resource of resources) { - for (let locale of Object.keys(locales)) { - items.push({resource: resource.slug, locale: locale}); + 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;