]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/build/client.sh
Fix build
[github/Chocobozzz/PeerTube.git] / scripts / build / client.sh
CommitLineData
10e63b68 1#!/bin/bash
b20b5fed 2
0e4ffb4b
LA
3set -eu
4
d73c9888 5pre_build_hook () {
350131cb
C
6 mkdir "./src/pending_locale" > /dev/null || true
7 mv ./src/locale/angular.*.xlf "./src/pending_locale"
d73c9888
C
8
9 if [ ! -z ${1+x} ]; then
350131cb 10 mv "./src/pending_locale/angular.$1.xlf" "./src/locale"
d73c9888
C
11 fi
12}
13
14post_build_hook () {
350131cb
C
15 mv ./src/pending_locale/* "./src/locale"
16 rmdir "./src/pending_locale/"
d73c9888
C
17}
18
95d51135 19# Previous build failed
350131cb
C
20if [ ! -f "client/src/locale/angular.fr-FR.xlf" ]; then
21 git checkout -- client/src/locale/
22 rm -r client/src/pending_locale
95d51135
C
23fi
24
0e4ffb4b 25cd client
b20b5fed 26
94edfc3b 27rm -rf ./dist ./compiled
d61e8153 28
d73c9888
C
29pre_build_hook
30
350131cb 31defaultLanguage="en-US"
989e526a
C
32npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json
33mv "./dist/$defaultLanguage/assets" "./dist"
65be133b 34mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
989e526a 35
d73c9888
C
36post_build_hook
37
e032aec9
C
38# Don't build other languages if --light arg is provided
39if [ -z ${1+x} ] || [ "$1" != "--light" ]; then
3dfa8494 40 if [ ! -z ${1+x} ] && [ "$1" == "--light-fr" ]; then
350131cb 41 languages=("fr-FR")
3dfa8494
C
42 else
43 # Supported languages
82054691 44 languages=(
350131cb
C
45 "fi-FI" "nl-NL" "gd" "el-GR" "es-ES" "oc" "pt-BR" "pt-PT" "sv-SE" "pl-PL" "ru-RU" "zh-Hans-CN" "zh-Hant-TW"
46 "fr-FR" "ja-JP" "eu-ES" "ca-ES" "cs-CZ" "eo" "de-DE" "it-IT"
82054691 47 )
3dfa8494 48 fi
e032aec9
C
49
50 for lang in "${languages[@]}"; do
d73c9888
C
51 # TODO: remove when the project will use runtime translations
52 pre_build_hook "$lang"
53
350131cb 54 npm run ng build -- --prod --i18n-file "./src/locale/angular.$lang.xlf" --i18n-format xlf --i18n-locale "$lang" \
e032aec9
C
55 --output-path "dist/$lang/" --deploy-url "/client/$lang/"
56
02ba6130 57 # Do not duplicate assets
e032aec9 58 rm -r "./dist/$lang/assets"
d73c9888
C
59
60 # TODO: remove when the project will use runtime translations
61 post_build_hook
e032aec9
C
62 done
63fi
989e526a 64
03d641a0 65cd ../ && npm run build:embed && cd client/
989e526a 66
96bb360d 67# Copy runtime locales
350131cb 68cp -r "./src/locale" "./dist/locale"