Update lang scripts using for loop for languages

This commit is contained in:
3d-gussner 2021-12-21 14:15:51 +01:00
parent e3e0ff0524
commit 2e776de9a9
8 changed files with 132 additions and 134 deletions

View File

@ -29,6 +29,16 @@ LNG=$1
# Params:
IGNORE_MISSING_TEXT=1
# List of supported languages
if [ -z "$LANGUAGES" ]; then
LANGUAGES="cz de es fr it pl"
fi
# Community languages
if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
LANGUAGES+=" $COMMUNITY_LANGUAGES"
fi
echo "fw-build languages:$LANGUAGES" >&2
finish()
{
@ -133,70 +143,20 @@ if [ ! -z "$LNG" ]; then
finish 0
else
echo "Updating languages:" >&2
if [ -e lang_cz.bin ]; then
echo -n " Czech : " >&2
./update_lang.sh cz 2>./update_lang_cz.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
if [ -e lang_de.bin ]; then
echo -n " German : " >&2
./update_lang.sh de 2>./update_lang_de.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
if [ -e lang_it.bin ]; then
echo -n " Italian: " >&2
./update_lang.sh it 2>./update_lang_it.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
if [ -e lang_es.bin ]; then
echo -n " Spanish: " >&2
./update_lang.sh es 2>./update_lang_es.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
if [ -e lang_fr.bin ]; then
echo -n " French : " >&2
./update_lang.sh fr 2>./update_lang_fr.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
if [ -e lang_pl.bin ]; then
echo -n " Polish : " >&2
./update_lang.sh pl 2>./update_lang_pl.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
#Community language support
#Dutch
if [ -e lang_nl.bin ]; then
echo -n " Dutch : " >&2
./update_lang.sh nl 2>./update_lang_nl.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; fi
fi
#Use the 6 lines below as a template and replace 'qr' and 'New language'
#New language
# if [ -e lang_qr.bin ]; then
# echo -n " New language : " >&2
# ./update_lang.sh qr 2>./update_lang_qr.out 1>/dev/null
# if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; fi
# fi
# echo "skipped" >&2
for lang in $LANGUAGES; do
if [ -e lang_$lang.bin ]; then
echo -n " $lang : " >&2
./update_lang.sh $lang 2>./update_lang_$lang.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
done
fi
#create binary file with all languages
rm -f lang.bin
if [ -e lang_cz.bin ]; then cat lang_cz.bin >> lang.bin; fi
if [ -e lang_de.bin ]; then cat lang_de.bin >> lang.bin; fi
if [ -e lang_es.bin ]; then cat lang_es.bin >> lang.bin; fi
if [ -e lang_fr.bin ]; then cat lang_fr.bin >> lang.bin; fi
if [ -e lang_it.bin ]; then cat lang_it.bin >> lang.bin; fi
if [ -e lang_pl.bin ]; then cat lang_pl.bin >> lang.bin; fi
#Community language support
# Dutch
if [ -e lang_nl.bin ]; then cat lang_nl.bin >> lang.bin; fi
#Use the 2 lines below as a template and replace 'qr'
## New language
#if [ -e lang_qr.bin ]; then cat lang_qr.bin >> lang.bin; fi
for lang in $LANGUAGES; do
if [ -e lang_$lang.bin ]; then cat lang_$lang.bin >> lang.bin; fi
done
# Check that the language data doesn't exceed the reserved XFLASH space
echo " checking language data size:"

View File

@ -4,6 +4,15 @@
# Remove all firmware output files from lang folder.
#
# Config:
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
LANGUAGES+=" $COMMUNITY_LANGUAGES"
fi
echo "fw-clean languages:$LANGUAGES" >&2
result=0
rm_if_exists()
@ -31,32 +40,17 @@ rm_if_exists progmem1.txt
rm_if_exists textaddr.txt
rm_if_exists firmware.bin
rm_if_exists firmware.hex
rm_if_exists firmware_cz.hex
rm_if_exists firmware_de.hex
rm_if_exists firmware_es.hex
rm_if_exists firmware_fr.hex
rm_if_exists firmware_it.hex
rm_if_exists firmware_pl.hex
rm_if_exists progmem.out
rm_if_exists textaddr.out
rm_if_exists update_lang.out
rm_if_exists update_lang_cz.out
rm_if_exists update_lang_de.out
rm_if_exists update_lang_es.out
rm_if_exists update_lang_fr.out
rm_if_exists update_lang_it.out
rm_if_exists update_lang_pl.out
rm_if_exists lang.bin
rm_if_exists lang.hex
#Community language support
#Dutch
rm_if_exists firmware_nl.hex
rm_if_exists update_lang_nl.out
#Use the 2 lines below as a template and replace 'qr'
##New language
#rm_if_exists firmware_qr.hex
#rm_if_exists update_lang_qr.out
for lang in $LANGUAGES; do
rm_if_exists firmware_$lang.hex
rm_if_exists update_lang_$lang.out
done
echo -n "fw-clean.sh finished" >&2
if [ $result -eq 0 ]; then

View File

@ -9,6 +9,15 @@
# lang_en.txt and all lang_en_xx.txt
#
# Config:
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
LANGUAGES+=" $COMMUNITY_LANGUAGES"
fi
echo "fw-clean languages:$LANGUAGES" >&2
# insert single text to english dictionary
# $1 - text to insert
@ -59,16 +68,10 @@ cat lang_add.txt | sed 's/^/"/;s/$/"/' | while read new_s; do
echo "adding text:"
echo "$new_s"
echo
insert_en "$new_s"
insert_xx "$new_s" 'cz'
insert_xx "$new_s" 'de'
insert_xx "$new_s" 'es'
insert_xx "$new_s" 'fr'
insert_xx "$new_s" 'it'
insert_xx "$new_s" 'pl'
#Community language support
#Dutch
insert_xx "$new_s" 'nl'
#insert_en "$new_s"
for lang in $LANGUAGES; do
insert_xx "$new_s" "$lang"
done
#Use the 2 lines below as a template and replace 'qr'
##New language

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# lang-build.sh - multi-language support script
# generate lang_xx.bin (language binary file)
@ -13,12 +13,21 @@
# lang_xx.tmp
# lang_xx.dat
#
# Config:
#startup message
echo "lang-build.sh started" >&2
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
LANGUAGES+=" $COMMUNITY_LANGUAGES"
fi
echo "lang-build languages:$LANGUAGES" >&2
#awk code to format ui16 variables for dd
awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }'
#startup message
echo "lang-build.sh started" >&2
#exiting function
finish()
@ -135,13 +144,10 @@ if [ -z "$1" ]; then set 'all'; fi
if [ "$1" = "all" ]; then
generate_binary 'en'
generate_binary 'cz'
generate_binary 'de'
generate_binary 'es'
generate_binary 'fr'
generate_binary 'it'
generate_binary 'pl'
#DO NOT add Community languages here !!!
for lang in $LANGUAGES; do
echo " Running : $lang" >&2
generate_binary $lang
done
else
generate_binary $1
fi

View File

@ -1,9 +1,18 @@
#!/bin/sh
#!/bin/bash
#
# clean.sh - multi-language support script
# Remove all language output files from lang folder.
#
# Config:
echo "CONFIG: $CONFIG_OK"
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
LANGUAGES+=" $COMMUNITY_LANGUAGES"
fi
result=0
rm_if_exists()
@ -37,18 +46,15 @@ clean_lang()
rm_if_exists lang_$1_2.tmp
}
echo "lang-clean.sh started" >&2
#Clean English
clean_lang en
clean_lang en
clean_lang cz
clean_lang de
clean_lang es
clean_lang fr
clean_lang it
clean_lang pl
#Community language support
#Dutch
clean_lang nl
#Clean languages
echo "lang-clean.sh started" >&2
echo "lang-clean languages:$LANGUAGES" >&2
for lang in $LANGUAGES; do
clean_lang $lang
done
#Use the 2 lines below as a template and replace 'qr'
##New language

View File

@ -10,8 +10,8 @@ if [ -z "$ROOT_PATH" ]; then
fi
# Check community language NL = Dutch
COMMUNITY_LANG_NL=$(grep --max-count=1 "^#define COMMUNITY_LANG_NL" $ROOT_PATH/Firmware/config.h| cut -d '_' -f3 |cut -d ' ' -f1)
export NL=$COMMUNITY_LANG_NL
COMMUNITY_LANG_GROUP1_NL=$(grep --max-count=1 "^#define COMMUNITY_LANG_GROUP1_NL" $ROOT_PATH/Firmware/config.h| cut -d '_' -f3 |cut -d ' ' -f1)
export NL=$COMMUNITY_LANG_GROUP1_NL
# Use the lines below as a template and replace 'QR' and 'new language'
# Check comminity language QR = new language
@ -24,8 +24,8 @@ echo -n " Source code path: " >&2
if [ -e $ROOT_PATH ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=1; fi
echo " Found: " >&2
if [ "$COMMUNITY_LANG_NL" = "NL" ]; then
echo " $COMMUNITY_LANG_NL" >&2
if [ "$COMMUNITY_LANG_GROUP1_NL" = "NL" ]; then
echo " $COMMUNITY_LANG_GROUP1_NL" >&2
echo
./lang-build.sh nl
fi

View File

@ -3,6 +3,14 @@
# lang-export.sh - multi-language support script
# for generating lang_xx.po
#
# Config:
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
LANGUAGES+=" $COMMUNITY_LANGUAGES"
fi
echo "lang-export languages:$LANGUAGES" >&2
# relative path to source folder
SRCDIR="../Firmware"
@ -16,18 +24,22 @@ if [ -z "$LNG" ]; then LNG=all; fi
# if 'all' is selected, script will generate all po files and also pot file
if [ "$LNG" = "all" ]; then
./lang-export.sh en
./lang-export.sh cz
./lang-export.sh de
./lang-export.sh es
./lang-export.sh fr
./lang-export.sh it
./lang-export.sh pl
for lang in $LANGUAGES; do
./lang-export.sh $lang
done
#./lang-export.sh cz
#./lang-export.sh de
#./lang-export.sh es
#./lang-export.sh fr
#./lang-export.sh it
#./lang-export.sh pl
#Community language support
#Dutch
./lang-export.sh nl
#Use the 2 lines below as a template and replace 'qr' and 'New language'
##New language
# ./lang-export.sh qr
#if [ -n "$COMMUNITY_LANGUAGES" ]; then
# for l in $COMMUNITY_LANGUAGES; do
# echo " Exporting : $l" >&2
# ./lang-export.sh $l
# done
#fi
exit 0
fi

View File

@ -2,6 +2,14 @@
#
# lang-import.sh - multi-language support script
# for importing translated xx.po
# Config:
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
LANGUAGES+=" $COMMUNITY_LANGUAGES"
fi
echo "lang-import languages:$LANGUAGES" >&2
LNG=$1
# if no arguments, 'all' is selected (all po and also pot will be generated)
@ -9,13 +17,22 @@ if [ -z "$LNG" ]; then LNG=all; fi
# if 'all' is selected, script will generate all po files and also pot file
if [ "$LNG" = "all" ]; then
./lang-import.sh cz
./lang-import.sh de
./lang-import.sh es
./lang-import.sh fr
./lang-import.sh it
./lang-import.sh pl
for lang in $LANGUAGES; do
./lang-import.sh $lang
done
#./lang-import.sh cz
#./lang-import.sh de
#./lang-import.sh es
#./lang-import.sh fr
#./lang-import.sh it
#./lang-import.sh pl
#DO NOT add Community languages here !!!
#if [ -n "$COMMUNITY_LANGUAGES" ]; then
# for l in $COMMUNITY_LANGUAGES; do
# echo " Exporting : $l" >&2
# ./lang-export.sh $l
# done
#fi
exit 0
fi