New ML support - script tunning + iso639

This commit is contained in:
Robert Pelnar 2018-06-21 18:59:11 +02:00
parent d70523c7d8
commit 1eed7cb1cd
5 changed files with 152 additions and 7 deletions

61
lang/fw-clean.sh Normal file
View File

@ -0,0 +1,61 @@
#!/bin/sh
#
# fw-clean.sh - multi-language support script
# Remove all firmware output files from lang folder.
#
result=0
rm_if_exists()
{
if [ -e $1 ]; then
echo -n " removing '$1'..." >&2
if rm $1; then
echo "OK" >&2
else
echo "NG!" >&2
result=1
fi
fi
}
echo "fw-clean.sh started" >&2
rm_if_exists text.sym
rm_if_exists progmem1.sym
rm_if_exists progmem1.lss
rm_if_exists progmem1.hex
rm_if_exists progmem1.chr
rm_if_exists progmem1.var
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_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_it.out
rm_if_exists update_lang_pl.out
rm_if_exists lang.bin
rm_if_exists lang.hex
echo -n "fw-clean.sh finished" >&2
if [ $result -eq 0 ]; then
echo " with success" >&2
else
echo " with errors!" >&2
fi
case "$-" in
*i*) echo "press enter key"; read ;;
esac
exit $result

10
lang/iso639-1.txt Normal file
View File

@ -0,0 +1,10 @@
#language codes ISO639-1
# iso english localized
#-----------------------
# en English English
# de German Deutsch
# cs Czech Cestina
# es Spanish Espanol
# fr
# it Italian Italiano
# pl Polish Polski

View File

@ -90,7 +90,8 @@ generate_binary()
cat lang_en_$1.txt | sed '/^$/d;/^#/d' | sed -n 'n;p' cat lang_en_$1.txt | sed '/^$/d;/^#/d' | sed -n 'n;p'
fi | sed 's/^\"\\x00\"$/\"\"/' > lang_$1.tmp fi | sed 's/^\"\\x00\"$/\"\"/' > lang_$1.tmp
#create lang_xx.dat (binary text data file) #create lang_xx.dat (binary text data file)
cat lang_$1.tmp | sed 's/^\"/printf \"/;s/"$/\\x00\"/' | sh >lang_$1.dat # cat lang_$1.tmp | sed 's/^\"/\/bin\/echo -e \"/;s/"$/\\x00\"/' > lang_$1.shx
cat lang_$1.tmp | sed 's/^\"/\/bin\/echo -e \"/;s/"$/\\x00\"/' | sh >lang_$1.dat
#calculate number of strings #calculate number of strings
count=$(grep -c '^"' lang_$1.tmp) count=$(grep -c '^"' lang_$1.tmp)
echo "count="$count >&2 echo "count="$count >&2
@ -118,8 +119,8 @@ generate_binary()
/bin/echo -n -e $(echo -n $((0x$chsum)) | awk "$awk_ui16") |\ /bin/echo -n -e $(echo -n $((0x$chsum)) | awk "$awk_ui16") |\
dd of=lang_$1.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null dd of=lang_$1.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
#remove temporary files #remove temporary files
rm -f lang_$1.tmp # rm -f lang_$1.tmp
rm -f lang_$1.dat # rm -f lang_$1.dat
} }
if [ -z "$1" ]; then set 'all'; fi if [ -z "$1" ]; then set 'all'; fi

57
lang/lang-clean.sh Normal file
View File

@ -0,0 +1,57 @@
#!/bin/sh
#
# clean.sh - multi-language support script
# Remove all language output files from lang folder.
#
result=0
rm_if_exists()
{
if [ -e $1 ]; then
echo -n " removing '$1'..." >&2
if rm $1; then
echo "OK" >&2
else
echo "NG!" >&2
result=1
fi
fi
}
clean_lang()
{
if [ "$1" = "en" ]; then
rm_if_exists lang_$1.tmp
else
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
fi
rm_if_exists lang_$1.bin
rm_if_exists lang_$1.dat
}
echo "lang-clean.sh started" >&2
clean_lang en
clean_lang cz
clean_lang de
clean_lang es
clean_lang fr
clean_lang it
clean_lang pl
echo -n "lang-clean.sh finished" >&2
if [ $result -eq 0 ]; then
echo " with success" >&2
else
echo " with errors!" >&2
fi
case "$-" in
*i*) echo "press enter key" >&2; read ;;
esac
exit $result

View File

@ -117,6 +117,11 @@ else
finish 1 finish 1
fi fi
#convert bin to hex
echo -n " converting to hex..." >&2
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware.hex
echo "OK" >&2
#update _SEC_LANG in binary file if language is selected #update _SEC_LANG in binary file if language is selected
echo -n " secondary language data..." >&2 echo -n " secondary language data..." >&2
if [ ! -z "$LNG" ]; then if [ ! -z "$LNG" ]; then
@ -154,9 +159,20 @@ else
# echo "skipped" >&2 # echo "skipped" >&2
fi fi
#convert bin to hex #create binary file with all languages
#echo -n " converting to hex..." >&2 rm -f lang.bin
#$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware.hex if [ -e lang_cz.bin ]; then cat lang_cz.bin >> lang.bin; fi
#echo "OK" >&2 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_it.bin ]; then cat lang_it.bin >> lang.bin; fi
if [ -e lang_pl.bin ]; then cat lang_pl.bin >> lang.bin; fi
#convert lang.bin to lang.hex
echo -n " converting to hex..." >&2
$OBJCOPY -I binary -O ihex ./lang.bin ./lang.hex
echo "OK" >&2
#append languages to hex file
cat ./lang.hex >> firmware.hex
finish 0 finish 0