build: i18n file download time with millisecond precision

This commit is contained in:
JimMoen 2024-01-31 15:52:46 +08:00
parent 52cfeee2b1
commit e57e19c9f1
No known key found for this signature in database
1 changed files with 9 additions and 6 deletions

View File

@ -29,17 +29,20 @@ I18N_REPO_BRANCH="v$(./pkg-vsn.sh "${PROFILE_STR}" | tr -d '.' | cut -c 1-2)"
DOWNLOAD_I18N_TRANSLATIONS=${DOWNLOAD_I18N_TRANSLATIONS:-true}
# download desc (i18n) translations
beginfmt='\033[1m'
endfmt='\033[0m'
if [ "$DOWNLOAD_I18N_TRANSLATIONS" = "true" ]; then
echo "downloading i18n translation from emqx/emqx-i18n"
start=$(date +%s)
echo "Downloading i18n translation from emqx/emqx-i18n..."
start=$(date +%s%N)
curl -L --fail --silent --show-error \
--output "apps/emqx_dashboard/priv/desc.zh.hocon" \
"https://raw.githubusercontent.com/emqx/emqx-i18n/${I18N_REPO_BRANCH}/desc.zh.hocon"
end=$(date +%s)
duration=$(echo "$end $start" | awk '{print $1 - $2}')
echo "downloaded i18n translation in $duration seconds, set DOWNLOAD_I18N_TRANSLATIONS=false to skip"
end=$(date +%s%N)
duration=$(echo "$end $start" | awk '{printf "%.f\n", (($1 - $2)/ 1000000)}')
if [ "$duration" -gt 1000 ]; then beginfmt='\033[1;33m'; fi
echo -e "Downloaded i18n translation in $duration milliseconds.\nSet ${beginfmt}DOWNLOAD_I18N_TRANSLATIONS=false${endfmt} to skip"
else
echo "skipping to download i18n translation from emqx/emqx-i18n, set DOWNLOAD_I18N_TRANSLATIONS=true to update"
echo -e "Skipping to download i18n translation from emqx/emqx-i18n.\nSet ${beginfmt}DOWNLOAD_I18N_TRANSLATIONS=true${endfmt} to update"
fi
# TODO