]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/build/client.sh
Update changelog
[github/Chocobozzz/PeerTube.git] / scripts / build / client.sh
CommitLineData
10e63b68 1#!/bin/bash
b20b5fed 2
0e4ffb4b
LA
3set -eu
4
361dcebc
C
5declare -A languages
6
d73c9888 7pre_build_hook () {
350131cb
C
8 mkdir "./src/pending_locale" > /dev/null || true
9 mv ./src/locale/angular.*.xlf "./src/pending_locale"
d73c9888
C
10
11 if [ ! -z ${1+x} ]; then
350131cb 12 mv "./src/pending_locale/angular.$1.xlf" "./src/locale"
d73c9888
C
13 fi
14}
15
16post_build_hook () {
350131cb
C
17 mv ./src/pending_locale/* "./src/locale"
18 rmdir "./src/pending_locale/"
d73c9888
C
19}
20
95d51135 21# Previous build failed
350131cb
C
22if [ ! -f "client/src/locale/angular.fr-FR.xlf" ]; then
23 git checkout -- client/src/locale/
24 rm -r client/src/pending_locale
95d51135
C
25fi
26
0e4ffb4b 27cd client
b20b5fed 28
94edfc3b 29rm -rf ./dist ./compiled
d61e8153 30
d73c9888
C
31pre_build_hook
32
350131cb 33defaultLanguage="en-US"
989e526a
C
34npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json
35mv "./dist/$defaultLanguage/assets" "./dist"
65be133b 36mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
989e526a 37
d73c9888
C
38post_build_hook
39
e032aec9
C
40# Don't build other languages if --light arg is provided
41if [ -z ${1+x} ] || [ "$1" != "--light" ]; then
5a208b00
I
42 if [ ! -z ${1+x} ] && [ "$1" == "--light-hu" ]; then
43 languages=(["hu"]="hu-HU")
520745bf 44 elif [ ! -z ${1+x} ] && [ "$1" == "--light-ar" ]; then
d10538b4 45 languages=(["ar"]="ar")
0bd558a0
C
46 elif [ ! -z ${1+x} ] && [ "$1" == "--light-vi" ]; then
47 languages=(["vi"]="vi-VN")
48 elif [ ! -z ${1+x} ] && [ "$1" == "--light-kab" ]; then
49 languages=(["kab"]="kab")
5a208b00
I
50 elif [ ! -z ${1+x} ] && [ "$1" == "--light-th" ]; then
51 languages=(["th"]="th-TH")
52 elif [ ! -z ${1+x} ] && [ "$1" == "--light-fi" ]; then
53 languages=(["fi"]="fi-FI")
54 elif [ ! -z ${1+x} ] && [ "$1" == "--light-nl" ]; then
55 languages=(["nl"]="nl-NL")
56 elif [ ! -z ${1+x} ] && [ "$1" == "--light-gd" ]; then
57 languages=(["gd"]="gd")
58 elif [ ! -z ${1+x} ] && [ "$1" == "--light-el" ]; then
59 languages=(["el"]="el-GR")
60 elif [ ! -z ${1+x} ] && [ "$1" == "--light-es" ]; then
61 languages=(["es"]="es-ES")
2a39506c
C
62 elif [ ! -z ${1+x} ] && [ "$1" == "--light-oc" ]; then
63 languages=(["oc"]="oc")
5a208b00
I
64 elif [ ! -z ${1+x} ] && [ "$1" == "--light-pt" ]; then
65 languages=(["pt"]="pt-BR")
66 elif [ ! -z ${1+x} ] && [ "$1" == "--light-pt-PT" ]; then
67 languages=(["pt-PT"]="pt-PT")
68 elif [ ! -z ${1+x} ] && [ "$1" == "--light-sv" ]; then
69 languages=(["sv"]="sv-SE")
70 elif [ ! -z ${1+x} ] && [ "$1" == "--light-pl" ]; then
71 languages=(["pl"]="pl-PL")
72 elif [ ! -z ${1+x} ] && [ "$1" == "--light-ru" ]; then
73 languages=(["ru"]="ru-RU")
74 elif [ ! -z ${1+x} ] && [ "$1" == "--light-zh-Hans" ]; then
75 languages=(["zh-Hans"]="zh-Hans-CN")
76 elif [ ! -z ${1+x} ] && [ "$1" == "--light-zh-Hant" ]; then
77 languages=(["zh-Hant"]="zh-Hant-TW")
78 elif [ ! -z ${1+x} ] && [ "$1" == "--light-fr" ]; then
361dcebc 79 languages=(["fr"]="fr-FR")
5a208b00
I
80 elif [ ! -z ${1+x} ] && [ "$1" == "--light-ja" ]; then
81 languages=(["ja"]="ja-JP")
82 elif [ ! -z ${1+x} ] && [ "$1" == "--light-eu" ]; then
83 languages=(["eu"]="eu-ES")
84 elif [ ! -z ${1+x} ] && [ "$1" == "--light-ca" ]; then
85 languages=(["ca"]="ca-ES")
86 elif [ ! -z ${1+x} ] && [ "$1" == "--light-cs" ]; then
87 languages=(["cs"]="cs-CZ")
88 elif [ ! -z ${1+x} ] && [ "$1" == "--light-eo" ]; then
89 languages=(["eo"]="eo")
90 elif [ ! -z ${1+x} ] && [ "$1" == "--light-de" ]; then
91 languages=(["de"]="de-DE")
92 elif [ ! -z ${1+x} ] && [ "$1" == "--light-it" ]; then
93 languages=(["it"]="it-IT")
3dfa8494
C
94 else
95 # Supported languages
82054691 96 languages=(
d10538b4 97 ["ar"]="ar"
0bd558a0 98 ["vi"]="vi-VN"
361dcebc
C
99 ["hu"]="hu-HU"
100 ["th"]="th-TH"
101 ["fi"]="fi-FI"
102 ["nl"]="nl-NL"
103 ["gd"]="gd"
104 ["el"]="el-GR"
105 ["es"]="es-ES"
2a39506c 106 ["oc"]="oc"
361dcebc
C
107 ["pt"]="pt-BR"
108 ["pt-PT"]="pt-PT"
109 ["sv"]="sv-SE"
110 ["pl"]="pl-PL"
111 ["ru"]="ru-RU"
112 ["zh-Hans"]="zh-Hans-CN"
113 ["zh-Hant"]="zh-Hant-TW"
114 ["fr"]="fr-FR"
115 ["ja"]="ja-JP"
116 ["eu"]="eu-ES"
117 ["ca"]="ca-ES"
118 ["cs"]="cs-CZ"
119 ["eo"]="eo"
120 ["de"]="de-DE"
121 ["it"]="it-IT"
0bd558a0 122 ["kab"]="kab"
82054691 123 )
3dfa8494 124 fi
e032aec9 125
361dcebc
C
126 for key in "${!languages[@]}"; do
127 lang=${languages[$key]}
128
d73c9888
C
129 # TODO: remove when the project will use runtime translations
130 pre_build_hook "$lang"
131
2779f29a 132 npm run ng build -- --prod --configuration="$lang" --output-path "dist/build"
361dcebc 133
2779f29a
C
134 # If --localize is not used
135 mv "dist/build/$key" "dist/$lang"
136 rmdir "dist/build"
137
138 # If --localize is used
139 # if [ ! "$lang" = "$key" ]; then
140 # mv "dist/$key" "dist/$lang"
141 # fi
e032aec9 142
02ba6130 143 # Do not duplicate assets
e032aec9 144 rm -r "./dist/$lang/assets"
d73c9888
C
145
146 # TODO: remove when the project will use runtime translations
147 post_build_hook
e032aec9
C
148 done
149fi
989e526a 150
03d641a0 151cd ../ && npm run build:embed && cd client/
989e526a 152
96bb360d 153# Copy runtime locales
350131cb 154cp -r "./src/locale" "./dist/locale"