diff --git a/build-scripts/gulp/download_translations.js b/build-scripts/gulp/download_translations.js index 6b13474e28..0d821b0a03 100644 --- a/build-scripts/gulp/download_translations.js +++ b/build-scripts/gulp/download_translations.js @@ -1,17 +1,12 @@ -const del = require("del"); const gulp = require("gulp"); const fs = require("fs"); const mapStream = require("map-stream"); const inDirFrontend = "translations/frontend"; const inDirBackend = "translations/backend"; -const downloadDir = "translations/downloads"; const srcMeta = "src/translations/translationMetadata.json"; - const encoding = "utf8"; -const tasks = []; - function hasHtml(data) { return /<[a-z][\s\S]*>/i.test(data); } @@ -46,20 +41,12 @@ function checkHtml() { }); } -let taskName = "clean-downloaded-translations"; -gulp.task(taskName, function () { - return del([`${downloadDir}/**`]); +// Backend translations do not currently pass HTML check so are excluded here for now +gulp.task("check-translations-html", function () { + return gulp.src([`${inDirFrontend}/*.json`]).pipe(checkHtml()); }); -tasks.push(taskName); -taskName = "check-translations-html"; -gulp.task(taskName, function () { - return gulp.src(`${downloadDir}/*.json`).pipe(checkHtml()); -}); -tasks.push(taskName); - -taskName = "check-all-files-exist"; -gulp.task(taskName, function () { +gulp.task("check-all-files-exist", function () { const file = fs.readFileSync(srcMeta, { encoding }); const meta = JSON.parse(file); Object.keys(meta).forEach((lang) => { @@ -72,24 +59,8 @@ gulp.task(taskName, function () { }); return Promise.resolve(); }); -tasks.push(taskName); -taskName = "move-downloaded-translations"; -gulp.task(taskName, function () { - return gulp.src(`${downloadDir}/*.json`).pipe(gulp.dest(inDirFrontend)); -}); -tasks.push(taskName); - -taskName = "check-downloaded-translations"; gulp.task( - taskName, - gulp.series( - "check-translations-html", - "move-downloaded-translations", - "check-all-files-exist", - "clean-downloaded-translations" - ) + "check-downloaded-translations", + gulp.series("check-translations-html", "check-all-files-exist") ); -tasks.push(taskName); - -module.exports = tasks; diff --git a/script/translations_download b/script/translations_download index 222ee4701d..25e0a61e02 100755 --- a/script/translations_download +++ b/script/translations_download @@ -20,24 +20,28 @@ fi # Load token from file if not already in the environment [ -z "${LOKALISE_TOKEN-}" ] && LOKALISE_TOKEN="$(<.lokalise_token)" -PROJECT_ID="3420425759f6d6d241f598.13594006" -LOCAL_DIR="$(pwd)/translations/downloads" -FILE_FORMAT=json +declare -A PROJECT_ID=( \ + [frontend]="3420425759f6d6d241f598.13594006" \ + [backend]="130246255a974bd3b5e8a1.51616605" \ + ) -mkdir -p ${LOCAL_DIR} - -docker run \ - -v ${LOCAL_DIR}:/opt/dest/locale \ - --rm \ - lokalise/lokalise-cli-2@sha256:f1860b26be22fa73b8c93bc5f8690f2afc867610a42de6fc27adc790e5d4425d lokalise2 \ - --token ${LOKALISE_TOKEN} \ - --project-id ${PROJECT_ID} \ - file download \ - --export-empty-as skip \ - --format json \ - --json-unescaped-slashes=true \ - --replace-breaks=false \ - --original-filenames=false \ - --unzip-to /opt/dest +for project in ${!PROJECT_ID[*]}; do +LOCAL_DIR=`pwd`/translations/${project} +rm -f ${LOCAL_DIR}/* || mkdir -p ${LOCAL_DIR} + docker run \ + -v ${LOCAL_DIR}:/opt/dest/locale \ + --rm \ + lokalise/lokalise-cli-2@sha256:f1860b26be22fa73b8c93bc5f8690f2afc867610a42de6fc27adc790e5d4425d \ + lokalise2 \ + --token ${LOKALISE_TOKEN} \ + --project-id ${PROJECT_ID[${project}]} \ + file download \ + --export-empty-as skip \ + --format json \ + --json-unescaped-slashes=true \ + --replace-breaks=false \ + --original-filenames=false \ + --unzip-to /opt/dest +done ./node_modules/.bin/gulp check-downloaded-translations \ No newline at end of file