2021-12-21 13:15:51 +00:00
|
|
|
#!/bin/bash
|
2018-06-21 16:59:11 +00:00
|
|
|
#
|
2022-03-16 08:23:34 +00:00
|
|
|
# Version 1.0.1 Build 13
|
2022-01-11 12:18:48 +00:00
|
|
|
#
|
2018-06-21 16:59:11 +00:00
|
|
|
# clean.sh - multi-language support script
|
|
|
|
# Remove all language output files from lang folder.
|
|
|
|
#
|
2022-01-11 12:18:48 +00:00
|
|
|
#############################################################################
|
|
|
|
# Change log:
|
|
|
|
# 1 Nov. 2018, XPila, Initial
|
2022-01-30 10:39:58 +00:00
|
|
|
# 18 Oct. 2018, XPila, New lang, arduino 1.8.5 - fw-clean.sh and lang-clean.sh fix
|
|
|
|
# 25 Oct. 2018, XPila, New lang - fixed french langcode and comparsion in lang-clean script
|
|
|
|
# 10 Dec. 2018, jhoblitt, make all shell scripts executable
|
|
|
|
# 26 Jul. 2019, leptun, Fix shifted languages. Use \n and \x0a
|
|
|
|
# 14 Sep. 2019, 3d-gussner, Prepare adding new language
|
|
|
|
# 01 Mar. 2021, 3d-gussner, Move `Dutch` language parts
|
|
|
|
# 22 Mar. 2021, 3d-gussner, Move Dutch removing part to correct loaction
|
|
|
|
# 21 Dec. 2021, 3d-gussner, Use one config file for all languages
|
|
|
|
# 03 Jan. 2022, 3d-gussner, Cleanup outdated code
|
2022-01-11 12:18:48 +00:00
|
|
|
# 11 Jan. 2022, 3d-gussner, Also remove temporally files which have been
|
|
|
|
# generated for message and size count comparison
|
|
|
|
# Added version and Change log
|
|
|
|
# colored output
|
|
|
|
# Add Community language support
|
|
|
|
# Use `git rev-list --count HEAD lang-clean.sh`
|
|
|
|
# to get Build Nr
|
2022-01-30 10:39:58 +00:00
|
|
|
# 25 Jan. 2022, 3d-gussner, clean up lang-import.sh temproray files
|
2022-02-14 07:39:03 +00:00
|
|
|
# 14 Feb. 2022, 3d-gussner, Fix single language run without config.sh OK
|
2022-03-16 08:23:34 +00:00
|
|
|
# 16 Mar. 2022, 3d-gussner, Cleanup `output-layout/sorted-??.txt`
|
2022-01-11 12:18:48 +00:00
|
|
|
#############################################################################
|
2018-06-21 16:59:11 +00:00
|
|
|
result=0
|
|
|
|
|
|
|
|
rm_if_exists()
|
|
|
|
{
|
|
|
|
if [ -e $1 ]; then
|
2022-01-11 12:18:48 +00:00
|
|
|
echo -n "$(tput sgr0) removing $(tput setaf 3)'$1'$(tput sgr0)..." >&2
|
2018-06-21 16:59:11 +00:00
|
|
|
if rm $1; then
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "$(tput setaf 2)OK$(tput sgr0)" >&2
|
2018-06-21 16:59:11 +00:00
|
|
|
else
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "$(tput setaf 1)NG!$(tput sgr0)" >&2
|
2018-06-21 16:59:11 +00:00
|
|
|
result=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
clean_lang()
|
|
|
|
{
|
2018-10-25 16:16:36 +00:00
|
|
|
if [ "$1" = "en" ]; then
|
2018-06-21 16:59:11 +00:00
|
|
|
rm_if_exists lang_$1.tmp
|
2022-01-11 12:18:48 +00:00
|
|
|
rm_if_exists lang_$1.cnt
|
|
|
|
rm_if_exists lang_$1.max
|
2018-06-21 16:59:11 +00:00
|
|
|
else
|
2018-10-18 11:08:12 +00:00
|
|
|
rm_if_exists lang_$1.tmp
|
2018-06-21 16:59:11 +00:00
|
|
|
rm_if_exists lang_en_$1.tmp
|
|
|
|
rm_if_exists lang_en_$1.dif
|
|
|
|
rm_if_exists lang_$1.ofs
|
|
|
|
rm_if_exists lang_$1.txt
|
2022-01-30 10:39:58 +00:00
|
|
|
rm_if_exists po/new/$1_new.po
|
|
|
|
rm_if_exists po/new/$1.mo
|
|
|
|
rm_if_exists po/new/$1_filtered.po
|
|
|
|
rm_if_exists po/new/lang_en_$1.txt
|
2022-03-16 08:23:34 +00:00
|
|
|
rm_if_exists po/new/output-layout-$1.txt
|
|
|
|
rm_if_exists po/new/output-sorted-$1.txt
|
2018-06-21 16:59:11 +00:00
|
|
|
fi
|
2018-10-18 11:08:12 +00:00
|
|
|
rm_if_exists lang_$1_check.dif
|
2018-06-21 16:59:11 +00:00
|
|
|
rm_if_exists lang_$1.bin
|
|
|
|
rm_if_exists lang_$1.dat
|
2018-10-18 11:08:12 +00:00
|
|
|
rm_if_exists lang_$1_1.tmp
|
|
|
|
rm_if_exists lang_$1_2.tmp
|
2022-01-30 10:39:58 +00:00
|
|
|
rm_if_exists po/new/nonascii.txt
|
|
|
|
|
2018-06-21 16:59:11 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "$(tput setaf 2)lang-clean.sh started$(tput sgr0)" >&2
|
2021-12-21 13:15:51 +00:00
|
|
|
#Clean English
|
|
|
|
clean_lang en
|
2018-06-21 16:59:11 +00:00
|
|
|
|
2021-12-21 13:15:51 +00:00
|
|
|
#Clean languages
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "lang-clean languages:$(tput setaf 2)$LANGUAGES$(tput sgr0)" >&2
|
2022-02-08 13:43:15 +00:00
|
|
|
if [ -e $1 ]; then
|
2022-02-14 07:39:03 +00:00
|
|
|
# Config:
|
|
|
|
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
|
|
|
|
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo "$(tput setaf 1)Config NG!$(tput sgr0)" >&2; exit 1; fi
|
|
|
|
|
|
|
|
if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
|
|
|
|
LANGUAGES+=" $COMMUNITY_LANGUAGES"
|
|
|
|
fi
|
|
|
|
|
2021-12-21 13:15:51 +00:00
|
|
|
for lang in $LANGUAGES; do
|
|
|
|
clean_lang $lang
|
|
|
|
done
|
2022-02-08 13:43:15 +00:00
|
|
|
else
|
|
|
|
clean_lang $1
|
|
|
|
fi
|
2021-03-01 07:28:08 +00:00
|
|
|
|
2018-06-21 16:59:11 +00:00
|
|
|
if [ $result -eq 0 ]; then
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "$(tput setaf 2) lang-clean.sh with success$(tput sgr0)" >&2
|
2018-06-21 16:59:11 +00:00
|
|
|
else
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "$(tput setaf 1) lang-clean.sh with errors!$(tput sgr0)" >&2
|
2018-06-21 16:59:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
case "$-" in
|
|
|
|
*i*) echo "press enter key" >&2; read ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $result
|