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