From 989e526abf0c0dd7958deb630df009608561bb67 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 31 May 2018 18:12:15 +0200 Subject: Prepare i18n files --- scripts/build/client.sh | 16 +++++++++++++++- scripts/i18n/generate.sh | 11 +++++++++++ scripts/i18n/pull-hook.sh | 7 +++++++ scripts/release.sh | 2 +- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100755 scripts/i18n/generate.sh create mode 100755 scripts/i18n/pull-hook.sh (limited to 'scripts') diff --git a/scripts/build/client.sh b/scripts/build/client.sh index 305af1e5f..61ba4ea99 100755 --- a/scripts/build/client.sh +++ b/scripts/build/client.sh @@ -6,5 +6,19 @@ cd client rm -rf ./dist ./compiled -npm run ng build -- --prod --stats-json +defaultLanguage="en-US" +npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json +mv "./dist/$defaultLanguage/assets" "./dist" + +languages="fr" + +for lang in "$languages"; do + npm run ng build -- --prod --i18n-file "./src/locale/target/messages_$lang.xml" --i18n-format xlf --i18n-locale "$lang" \ + --output-path "dist/$lang/" --deploy-url "/client/$lang/" + + # Do no duplicate assets + rm -r "./dist/$lang/assets" +done + NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js --mode production + diff --git a/scripts/i18n/generate.sh b/scripts/i18n/generate.sh new file mode 100755 index 000000000..429523ba4 --- /dev/null +++ b/scripts/i18n/generate.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -eu + +cd client +npm run ng -- xi18n --i18n-locale "en-US" --output-path locale/source --out-file messages_en_US.xml +npm run ngx-extractor -- --locale "en-US" -i 'src/**/*.ts' -f xlf -o src/locale/source/messages_en_US.xml + +# Zanata does not support inner elements in , so we hack these special elements +# This regex translate the Angular elements to special entities (that we will reconvert on pull) +sed -i 's//\<x id=\1\/\>/g' src/locale/source/messages_en_US.xml \ No newline at end of file diff --git a/scripts/i18n/pull-hook.sh b/scripts/i18n/pull-hook.sh new file mode 100755 index 000000000..cb969f83c --- /dev/null +++ b/scripts/i18n/pull-hook.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -eu + +# Zanata does not support inner elements in , so we hack these special elements +# This regex translate the converted elements to initial Angular elements +sed -i 's/\<x id=\([^\/]\+\?\)\/\>//g' client/src/locale/target/* \ No newline at end of file diff --git a/scripts/release.sh b/scripts/release.sh index 8c73a1fd6..393955264 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -57,7 +57,7 @@ git commit package.json client/package.json -m "Bumped to version $version" git tag -s -a "$version" -m "$version" npm run build -rm "./client/dist/stats.json" +rm "./client/dist/en-US/stats.json" # Creating the archives ( -- cgit v1.2.3