diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-25 09:57:52 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-25 09:57:52 +0200 |
commit | d73c98884ec7f970ed95a01fb2d445d10c53c817 (patch) | |
tree | 150d13e61a6954ea6393788c4fe2de3b28392fac | |
parent | a8bf1d826e379dec03d25840c7c49c1f30168380 (diff) | |
download | PeerTube-d73c98884ec7f970ed95a01fb2d445d10c53c817.tar.gz PeerTube-d73c98884ec7f970ed95a01fb2d445d10c53c817.tar.zst PeerTube-d73c98884ec7f970ed95a01fb2d445d10c53c817.zip |
Hack 459 regarding Angular & i18n
-rwxr-xr-x | scripts/build/client.sh | 24 | ||||
-rw-r--r-- | server/controllers/client.ts | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/scripts/build/client.sh b/scripts/build/client.sh index e4d053e82..567a6e5e0 100755 --- a/scripts/build/client.sh +++ b/scripts/build/client.sh | |||
@@ -2,25 +2,49 @@ | |||
2 | 2 | ||
3 | set -eu | 3 | set -eu |
4 | 4 | ||
5 | pre_build_hook () { | ||
6 | mkdir "./src/locale/pending_target/" > /dev/null || true | ||
7 | mv ./src/locale/target/angular_*.xml "./src/locale/pending_target" | ||
8 | |||
9 | if [ ! -z ${1+x} ]; then | ||
10 | mv "./src/locale/pending_target/angular_$1.xml" "./src/locale/target" | ||
11 | fi | ||
12 | } | ||
13 | |||
14 | post_build_hook () { | ||
15 | mv ./src/locale/pending_target/* "./src/locale/target/" | ||
16 | rmdir "./src/locale/pending_target/" | ||
17 | } | ||
18 | |||
5 | cd client | 19 | cd client |
6 | 20 | ||
7 | rm -rf ./dist ./compiled | 21 | rm -rf ./dist ./compiled |
8 | 22 | ||
23 | pre_build_hook | ||
24 | |||
9 | defaultLanguage="en_US" | 25 | defaultLanguage="en_US" |
10 | npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json | 26 | npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json |
11 | mv "./dist/$defaultLanguage/assets" "./dist" | 27 | mv "./dist/$defaultLanguage/assets" "./dist" |
12 | 28 | ||
29 | post_build_hook | ||
30 | |||
13 | # Don't build other languages if --light arg is provided | 31 | # Don't build other languages if --light arg is provided |
14 | if [ -z ${1+x} ] || [ "$1" != "--light" ]; then | 32 | if [ -z ${1+x} ] || [ "$1" != "--light" ]; then |
15 | # Supported languages | 33 | # Supported languages |
16 | languages=("fr_FR" "eu_ES" "ca_ES" "cs_CZ" "eo") | 34 | languages=("fr_FR" "eu_ES" "ca_ES" "cs_CZ" "eo") |
17 | 35 | ||
18 | for lang in "${languages[@]}"; do | 36 | for lang in "${languages[@]}"; do |
37 | # TODO: remove when the project will use runtime translations | ||
38 | pre_build_hook "$lang" | ||
39 | |||
19 | npm run ng build -- --prod --i18n-file "./src/locale/target/angular_$lang.xml" --i18n-format xlf --i18n-locale "$lang" \ | 40 | npm run ng build -- --prod --i18n-file "./src/locale/target/angular_$lang.xml" --i18n-format xlf --i18n-locale "$lang" \ |
20 | --output-path "dist/$lang/" --deploy-url "/client/$lang/" | 41 | --output-path "dist/$lang/" --deploy-url "/client/$lang/" |
21 | 42 | ||
22 | # Do no duplicate assets | 43 | # Do no duplicate assets |
23 | rm -r "./dist/$lang/assets" | 44 | rm -r "./dist/$lang/assets" |
45 | |||
46 | # TODO: remove when the project will use runtime translations | ||
47 | post_build_hook | ||
24 | done | 48 | done |
25 | fi | 49 | fi |
26 | 50 | ||
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index bbb518c1b..c33061289 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -89,7 +89,7 @@ export { | |||
89 | // --------------------------------------------------------------------------- | 89 | // --------------------------------------------------------------------------- |
90 | 90 | ||
91 | async function generateHTMLPage (req: express.Request, res: express.Response, paramLang?: string) { | 91 | async function generateHTMLPage (req: express.Request, res: express.Response, paramLang?: string) { |
92 | const html = await ClientHtml.getIndexHTML(req, res) | 92 | const html = await ClientHtml.getIndexHTML(req, res, paramLang) |
93 | 93 | ||
94 | return sendHTML(html, res) | 94 | return sendHTML(html, res) |
95 | } | 95 | } |