From 66b0b1afa8a5f97d1d82d5bbd1e89afd4d46b3cb Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sun, 8 Dec 2019 00:33:50 +0100 Subject: [PATCH] fixing language issue --- .travis.yml | 1 - README.md | 3 ++- frontend/app/app.module.ts | 2 +- gulpfile.ts | 22 +++++++++++++++++++--- package.json | 5 +++-- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index a63184a0..ef1afd0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ dist: trusty language: node_js node_js: - '10' - - '11' - '12' - '13' env: diff --git a/README.md b/README.md index 463ba02a..c347e3c6 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ unzip master.zip cd pigallery2-master # enter the unzipped directory npm install ``` -**Note**: if you run `npm run build-release`, it creates a clean, minified, production ready version from the app in the `release` folder, that is ready to deploy. +**Note**: if you run `npm run create-release`, it creates a clean, minified, production ready version from the app in the `release` folder, that is ready to deploy. +**Note**: you can use `npm run create-release -- --languages=fr,ro` to restrict building to the listed languages (english is added by default) #### 1.1.2 Run PiGallery2 ```bash diff --git a/frontend/app/app.module.ts b/frontend/app/app.module.ts index 81298fea..b4039f65 100644 --- a/frontend/app/app.module.ts +++ b/frontend/app/app.module.ts @@ -125,7 +125,7 @@ export function translationsFactory(locale: string) { if (locale === 'en') { return ''; } - return require(`raw-loader!../translate/messages.${locale}.xlf`); + return (require(`raw-loader!../translate/messages.${locale}.xlf`)).default; } @NgModule({ diff --git a/gulpfile.ts b/gulpfile.ts index 8d86f0af..e1400c7e 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -43,9 +43,25 @@ const getLanguages = () => { const files: string[] = dirCont.filter((elm) => { return elm.match(/.*\.[a-zA-Z]+\.(xlf)/ig); }); - return files.map((f: string) => { + + // get languages to filter + let languageFilter: string[] = null; + for (let i = 0; i < process.argv.length; i++) { + if (process.argv[i].startsWith('--languages=')) { + languageFilter = process.argv[i].replace('--languages=', '').split(','); + } + } + + let languages = files.map((f: string) => { return f.split('.')[1]; }); + + if (languageFilter !== null) { + languages = languages.filter((l) => { + return languageFilter.indexOf(l) !== -1; + }); + } + return languages; }; gulp.task('build-frontend', (() => { @@ -98,11 +114,11 @@ gulp.task('zip-release', function () { .pipe(gulp.dest('.')); }); -gulp.task('build-release', gulp.series('build-frontend', 'build-backend', 'copy-static', 'copy-package', 'zip-release')); +gulp.task('create-release', gulp.series('build-frontend', 'build-backend', 'copy-static', 'copy-package', 'zip-release')); const simpleBuild = (isProd: boolean) => { - const languages = getLanguages().filter(function (l) { + const languages = getLanguages().filter((l) => { return l !== 'en'; }); const tasks = []; diff --git a/package.json b/package.json index 78d7e163..b09e7f1b 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,9 @@ "main": "./backend/index.js", "bin": "./backend/index.js", "scripts": { - "install": "tsc && gulp build-prod", - "build-release": "gulp build-release", + "install": "npm run build-prod", + "build-prod": "tsc && gulp build-prod", + "create-release": "gulp build-release", "build-backend": "tsc", "pretest": "tsc", "test": "ng test && mocha --recursive test/backend/unit && mocha --recursive test/backend/integration && mocha --recursive test/common/unit ",