2018-06-28 07:56:46 -05:00
|
|
|
#!/bin/bash
|
2016-06-03 15:47:55 -05:00
|
|
|
|
2018-03-27 03:35:12 -05:00
|
|
|
set -eu
|
|
|
|
|
2020-02-07 08:51:19 -06:00
|
|
|
declare -A languages
|
2020-08-12 03:40:04 -05:00
|
|
|
defaultLanguage="en-US"
|
2020-02-07 08:51:19 -06:00
|
|
|
|
2020-08-12 03:40:04 -05:00
|
|
|
# Supported languages
|
|
|
|
languages=(
|
|
|
|
["ar"]="ar"
|
2022-03-03 03:54:52 -06:00
|
|
|
["fa"]="fa-IR"
|
2020-08-12 03:40:04 -05:00
|
|
|
["en"]="en-US"
|
|
|
|
["vi"]="vi-VN"
|
|
|
|
["hu"]="hu-HU"
|
|
|
|
["th"]="th-TH"
|
|
|
|
["fi"]="fi-FI"
|
|
|
|
["nl"]="nl-NL"
|
|
|
|
["gd"]="gd"
|
|
|
|
["el"]="el-GR"
|
|
|
|
["es"]="es-ES"
|
|
|
|
["oc"]="oc"
|
|
|
|
["pt"]="pt-BR"
|
|
|
|
["pt-PT"]="pt-PT"
|
|
|
|
["sv"]="sv-SE"
|
|
|
|
["pl"]="pl-PL"
|
|
|
|
["ru"]="ru-RU"
|
|
|
|
["zh-Hans"]="zh-Hans-CN"
|
|
|
|
["zh-Hant"]="zh-Hant-TW"
|
|
|
|
["fr"]="fr-FR"
|
|
|
|
["ja"]="ja-JP"
|
|
|
|
["eu"]="eu-ES"
|
|
|
|
["ca"]="ca-ES"
|
2020-12-16 04:45:12 -06:00
|
|
|
["gl"]="gl-ES"
|
2020-08-12 03:40:04 -05:00
|
|
|
["cs"]="cs-CZ"
|
|
|
|
["eo"]="eo"
|
|
|
|
["de"]="de-DE"
|
|
|
|
["it"]="it-IT"
|
2021-03-09 04:34:46 -06:00
|
|
|
["sq"]="sq"
|
2021-12-13 10:06:44 -06:00
|
|
|
["nn"]="nn"
|
|
|
|
["nb"]="nb-NO"
|
2020-08-12 03:40:04 -05:00
|
|
|
["kab"]="kab"
|
|
|
|
)
|
2018-08-16 04:11:20 -05:00
|
|
|
|
2018-03-27 03:35:12 -05:00
|
|
|
cd client
|
2016-06-03 15:47:55 -05:00
|
|
|
|
2021-06-17 03:43:34 -05:00
|
|
|
rm -rf ./dist
|
2017-04-26 14:46:56 -05:00
|
|
|
|
2018-07-18 02:52:46 -05:00
|
|
|
# Don't build other languages if --light arg is provided
|
2020-11-26 01:52:43 -06:00
|
|
|
if [ -z ${1+x} ] || ([ "$1" != "--light" ] && [ "$1" != "--analyze-bundle" ]); then
|
2021-02-02 08:33:58 -06:00
|
|
|
additionalParams=""
|
|
|
|
if [ ! -z ${1+x} ] && [ "$1" == "--source-map" ]; then
|
|
|
|
additionalParams="--sourceMap=true"
|
|
|
|
fi
|
|
|
|
|
2021-07-05 08:19:23 -05:00
|
|
|
node --max_old_space_size=8192 node_modules/.bin/ng build --configuration production --output-path "dist/build" $additionalParams
|
2018-07-18 02:52:46 -05:00
|
|
|
|
2020-02-07 08:51:19 -06:00
|
|
|
for key in "${!languages[@]}"; do
|
|
|
|
lang=${languages[$key]}
|
|
|
|
|
2020-08-12 03:40:04 -05:00
|
|
|
mv "dist/build/$key" "dist/$lang"
|
2018-07-25 02:57:52 -05:00
|
|
|
|
2020-08-12 03:40:04 -05:00
|
|
|
if [ "$lang" != "en-US" ]; then
|
|
|
|
# Do not duplicate assets
|
|
|
|
rm -r "./dist/$lang/assets"
|
|
|
|
fi
|
|
|
|
done
|
2020-02-07 08:51:19 -06:00
|
|
|
|
2020-08-12 03:40:04 -05:00
|
|
|
mv "./dist/$defaultLanguage/assets" "./dist"
|
2020-02-12 07:09:24 -06:00
|
|
|
|
2020-08-12 03:40:04 -05:00
|
|
|
rmdir "dist/build"
|
|
|
|
else
|
|
|
|
additionalParams=""
|
|
|
|
if [ ! -z ${1+x} ] && [ "$1" == "--analyze-bundle" ]; then
|
|
|
|
additionalParams="--namedChunks=true --outputHashing=none"
|
2021-08-18 03:32:40 -05:00
|
|
|
|
|
|
|
# For webpack
|
2020-08-12 03:40:04 -05:00
|
|
|
export ANALYZE_BUNDLE=true
|
|
|
|
fi
|
2018-07-18 02:52:46 -05:00
|
|
|
|
2021-07-05 08:19:23 -05:00
|
|
|
node --max_old_space_size=8192 node_modules/.bin/ng build --localize=false --output-path "dist/$defaultLanguage/" \
|
2021-05-14 09:56:44 -05:00
|
|
|
--deploy-url "/client/$defaultLanguage/" --configuration production --stats-json $additionalParams
|
2018-07-18 02:52:46 -05:00
|
|
|
fi
|
2018-05-31 11:12:15 -05:00
|
|
|
|
2021-01-18 04:16:37 -06:00
|
|
|
cp "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
|
2020-12-12 21:15:27 -06:00
|
|
|
|
2020-08-06 03:26:39 -05:00
|
|
|
cd ../ && npm run build:embed && cd client/
|
2018-05-31 11:12:15 -05:00
|
|
|
|
2018-06-06 11:17:24 -05:00
|
|
|
# Copy runtime locales
|
2019-11-07 08:33:23 -06:00
|
|
|
cp -r "./src/locale" "./dist/locale"
|