Use transifex .download() to download

Undo tr change
This commit is contained in:
seotts 2022-03-22 16:29:53 -04:00 committed by Cori Hudson
parent 842704fb55
commit dd2ed99ece
6 changed files with 5354 additions and 3957 deletions

View file

@ -29,9 +29,9 @@ if (!process.env.TX_TOKEN || args.length < 3) {
import fs from 'fs';
import path from 'path';
import {txPull} from '../lib/transifex.js';
import async from 'async';
import {validateTranslations} from '../lib/validate.js';
import locales, {localeMap} from '../src/supported-locales.js';
import {batchMap} from '../lib/batch.js';
// Globals
const PROJECT = args[0];
@ -43,7 +43,6 @@ const CONCURRENCY_LIMIT = 36;
const getLocaleData = async function (locale) {
let txLocale = localeMap[locale] || locale;
const data = await txPull(PROJECT, RESOURCE, txLocale, MODE);
return {
locale: locale,
translations: data
@ -52,8 +51,8 @@ const getLocaleData = async function (locale) {
const pullTranslations = async function () {
try {
const values = await async.mapLimit(Object.keys(locales), CONCURRENCY_LIMIT, getLocaleData);
const values = await batchMap(Object.keys(locales), CONCURRENCY_LIMIT, getLocaleData);
const source = values.find(elt => elt.locale === 'en').translations;
values.forEach(function (translation) {
validateTranslations({locale: translation.locale, translations: translation.translations}, source);
@ -64,7 +63,7 @@ const pullTranslations = async function () {
);
});
} catch (err) {
console.error(err); // eslint-disable-line no-console
process.stdout.write(err);
process.exit(1);
}
};

View file

@ -31,14 +31,14 @@ import fs from 'fs';
import path from 'path';
import mkdirp from 'mkdirp';
import {txPull, txResources} from '../lib/transifex.js';
import async from 'async';
import locales, {localeMap} from '../src/supported-locales.js';
import {batchMap} from '../lib/batch.js';
// Globals
const PROJECT = 'scratch-website';
const OUTPUT_DIR = path.resolve(args[0]);
// const MODE = {mode: 'reviewed'}; // default is everything for www
const CONCURRENCY_LIMIT = 4;
const CONCURRENCY_LIMIT = 36;
const lang = args.length === 2 ? args[1] : '';
@ -82,7 +82,7 @@ const pullTranslations = async function () {
const allFiles = expandResourceFiles(resources);
try {
await async.mapLimit(allFiles, CONCURRENCY_LIMIT, getLocaleData);
await batchMap(allFiles, CONCURRENCY_LIMIT, getLocaleData);
} catch (err) {
console.error(err); // eslint-disable-line no-console
process.exit(1);