New ML support - scripts tunning
This commit is contained in:
parent
5a2b056d47
commit
7ab53af604
3 changed files with 43 additions and 37 deletions
|
@ -20,34 +20,26 @@ if [ -z "$LANG" ]; then LANG='cz'; fi
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ "$LANG" == "all" ]; then
|
finish()
|
||||||
./make_lang.sh cz
|
|
||||||
./make_lang.sh de
|
|
||||||
./make_lang.sh es
|
|
||||||
./make_lang.sh it
|
|
||||||
./make_lang.sh pl
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
function finish
|
|
||||||
{
|
{
|
||||||
if [ "$1" == "0" ]; then
|
if [ $1 -eq 0 ]; then
|
||||||
if [ -e lang_en.tmp ]; then rm lang_en.tmp; fi
|
if [ -e lang_en.tmp ]; then rm lang_en.tmp; fi
|
||||||
if [ -e lang_en_$LANG.tmp ]; then rm lang_en_$LANG.tmp; fi
|
if [ -e lang_en_$LANG.tmp ]; then rm lang_en_$LANG.tmp; fi
|
||||||
if [ -e lang_en_$LANG.dif ]; then rm lang_en_$LANG.dif; fi
|
if [ -e lang_en_$LANG.dif ]; then rm lang_en_$LANG.dif; fi
|
||||||
fi
|
fi
|
||||||
echo
|
# echo >&2
|
||||||
if [ "$1" == "0" ]; then
|
if [ $1 -eq 0 ]; then
|
||||||
echo "make_lang.sh finished with success" >&2
|
echo "make_lang.sh finished with success" >&2
|
||||||
else
|
else
|
||||||
echo "make_lang.sh finished with errors!" >&2
|
echo "make_lang.sh finished with errors!" >&2
|
||||||
fi
|
fi
|
||||||
case "$-" in
|
|
||||||
*i*) echo "press enter key"; read ;;
|
|
||||||
esac
|
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
make_lang()
|
||||||
|
{
|
||||||
|
LANG=$1
|
||||||
|
|
||||||
echo "make_lang.sh started" >&2
|
echo "make_lang.sh started" >&2
|
||||||
echo "selected language=$LANG" >&2
|
echo "selected language=$LANG" >&2
|
||||||
|
|
||||||
|
@ -84,7 +76,7 @@ echo -n " generating lang_$LANG.dat..." >&2
|
||||||
cat lang_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do
|
cat lang_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do
|
||||||
s=${s#\"}
|
s=${s#\"}
|
||||||
s=${s%\"}
|
s=${s%\"}
|
||||||
echo -n -e "$s"'\x00'
|
/bin/echo -e -n "$s\x00"
|
||||||
done >lang_$LANG.dat
|
done >lang_$LANG.dat
|
||||||
echo "OK" >&2
|
echo "OK" >&2
|
||||||
|
|
||||||
|
@ -114,22 +106,22 @@ awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }'
|
||||||
#write data to binary file with dd
|
#write data to binary file with dd
|
||||||
|
|
||||||
echo -n " writing header (16 bytes)..." >&2
|
echo -n " writing header (16 bytes)..." >&2
|
||||||
echo -n -e "$lt_magic" |\
|
/bin/echo -n -e "$lt_magic" |\
|
||||||
dd of=lang_$LANG.bin bs=1 count=4 seek=0 conv=notrunc 2>/dev/null
|
dd of=lang_$LANG.bin bs=1 count=4 seek=0 conv=notrunc 2>/dev/null
|
||||||
echo -n -e $(echo -n "$lt_size" | awk "$awk_ui16") |\
|
/bin/echo -n -e $(echo -n "$lt_size" | awk "$awk_ui16") |\
|
||||||
dd of=lang_$LANG.bin bs=1 count=2 seek=4 conv=notrunc 2>/dev/null
|
dd of=lang_$LANG.bin bs=1 count=2 seek=4 conv=notrunc 2>/dev/null
|
||||||
echo -n -e $(echo -n "$lt_count" | awk "$awk_ui16") |\
|
/bin/echo -n -e $(echo -n "$lt_count" | awk "$awk_ui16") |\
|
||||||
dd of=lang_$LANG.bin bs=1 count=2 seek=6 conv=notrunc 2>/dev/null
|
dd of=lang_$LANG.bin bs=1 count=2 seek=6 conv=notrunc 2>/dev/null
|
||||||
echo -n -e $(echo -n "$lt_chsum" | awk "$awk_ui16") |\
|
/bin/echo -n -e $(echo -n "$lt_chsum" | awk "$awk_ui16") |\
|
||||||
dd of=lang_$LANG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
|
dd of=lang_$LANG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
|
||||||
echo -n -e "$lt_resv0" |\
|
/bin/echo -n -e "$lt_resv0" |\
|
||||||
dd of=lang_$LANG.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null
|
dd of=lang_$LANG.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null
|
||||||
echo -n -e "$lt_resv1" |\
|
/bin/echo -n -e "$lt_resv1" |\
|
||||||
dd of=lang_$LANG.bin bs=1 count=4 seek=12 conv=notrunc 2>/dev/null
|
dd of=lang_$LANG.bin bs=1 count=4 seek=12 conv=notrunc 2>/dev/null
|
||||||
echo "OK" >&2
|
echo "OK" >&2
|
||||||
|
|
||||||
echo -n " writing offset table ($lt_offs_size bytes)..." >&2
|
echo -n " writing offset table ($lt_offs_size bytes)..." >&2
|
||||||
echo -n -e $(cat lang_$LANG.ofs | awk "$awk_ui16" | tr -d '\n'; echo) |\
|
/bin/echo -n -e $(cat lang_$LANG.ofs | awk "$awk_ui16" | tr -d '\n'; echo) |\
|
||||||
dd of=./lang_$LANG.bin bs=1 count=$lt_offs_size seek=16 conv=notrunc 2>/dev/null
|
dd of=./lang_$LANG.bin bs=1 count=$lt_offs_size seek=16 conv=notrunc 2>/dev/null
|
||||||
echo "OK" >&2
|
echo "OK" >&2
|
||||||
|
|
||||||
|
@ -141,8 +133,19 @@ echo " lang_table details:" >&2
|
||||||
echo " lt_count = $lt_count" >&2
|
echo " lt_count = $lt_count" >&2
|
||||||
echo " lt_size = $lt_size" >&2
|
echo " lt_size = $lt_size" >&2
|
||||||
echo " lt_chsum = $lt_chsum" >&2
|
echo " lt_chsum = $lt_chsum" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $LANG
|
||||||
|
|
||||||
|
if [ "$LANG" = "all" ]; then
|
||||||
|
make_lang cz
|
||||||
|
make_lang de
|
||||||
|
make_lang es
|
||||||
|
make_lang it
|
||||||
|
make_lang pl
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
make_lang $LANG
|
||||||
|
fi
|
||||||
|
|
||||||
finish 0
|
finish 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -81,19 +81,19 @@ cat ../lang_en_$LANG.txt | sed "s/\\\\/\\\\\\\\/g;s/^#/#: /" | while read -r s;
|
||||||
if [ "$s" == "" ]; then
|
if [ "$s" == "" ]; then
|
||||||
echo " processing $num of $num_texts" >&2
|
echo " processing $num of $num_texts" >&2
|
||||||
if [ "$s0" == "\"\\\\x00\"" ]; then
|
if [ "$s0" == "\"\\\\x00\"" ]; then
|
||||||
search=$(echo -e "$s1")
|
search=$(/bin/echo -e "$s1")
|
||||||
found=$(grep -m1 -n -F "$search" $files | head -n1 | cut -f1-2 -d':' | sed "s/^.*\///")
|
found=$(grep -m1 -n -F "$search" $files | head -n1 | cut -f1-2 -d':' | sed "s/^.*\///")
|
||||||
echo "#: $found"
|
echo "#: $found"
|
||||||
echo "#, fuzzy"
|
echo "#, fuzzy"
|
||||||
echo -e "msgid $s1"
|
/bin/echo -e "msgid $s1"
|
||||||
echo 'msgstr ""'
|
echo 'msgstr ""'
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
search=$(echo -e "$s1")
|
search=$(/bin/echo -e "$s1")
|
||||||
found=$(grep -m1 -n -F "$search" $files | head -n1 | cut -f1-2 -d':' | sed "s/^.*\///")
|
found=$(grep -m1 -n -F "$search" $files | head -n1 | cut -f1-2 -d':' | sed "s/^.*\///")
|
||||||
echo "#: $found"
|
echo "#: $found"
|
||||||
echo -e "msgid $s1"
|
/bin/echo -e "msgid $s1"
|
||||||
echo -e "msgstr $s0"
|
/bin/echo -e "msgstr $s0"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
num=$((num+1))
|
num=$((num+1))
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
# $PROGMEM.hex - variables - hex
|
# $PROGMEM.hex - variables - hex
|
||||||
# $PROGMEM.chr - variables - char escape
|
# $PROGMEM.chr - variables - char escape
|
||||||
# $PROGMEM.var - variables - strings
|
# $PROGMEM.var - variables - strings
|
||||||
# $PROGMEM.txt - text data only
|
# $PROGMEM.txt - text data only (not used)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Config:
|
# Config:
|
||||||
|
@ -86,7 +86,7 @@ echo " progmem.sh (5) - calculating start and stop address" >&2
|
||||||
#calculate start addres of section ".$PROGMEM"
|
#calculate start addres of section ".$PROGMEM"
|
||||||
PROGMEM_BEG=$(head -n1 $PROGMEM.sym | while read offs size name; do echo "0x"$offs; done)
|
PROGMEM_BEG=$(head -n1 $PROGMEM.sym | while read offs size name; do echo "0x"$offs; done)
|
||||||
#calculate stop addres of section ".$PROGMEM"
|
#calculate stop addres of section ".$PROGMEM"
|
||||||
PROGMEM_END=$(tail -n1 $PROGMEM.sym | while read offs size name; do printf "0x%x" $(("0x"$offs + "0x"$size)); done)
|
PROGMEM_END=$(tail -n1 $PROGMEM.sym | while read offs size name; do printf "0x%x" $((0x$offs + 0x$size)); done)
|
||||||
echo " START address = "$PROGMEM_BEG >&2
|
echo " START address = "$PROGMEM_BEG >&2
|
||||||
echo " STOP address = "$PROGMEM_END >&2
|
echo " STOP address = "$PROGMEM_END >&2
|
||||||
|
|
||||||
|
@ -112,8 +112,9 @@ echo " progmem.sh (7) - preparing string data" >&2
|
||||||
# replace all tabs with spaces
|
# replace all tabs with spaces
|
||||||
cat $PROGMEM.hex | sed 's/ /\t/;s/ /\t /;s/ /\\x/g;s/\t/ /g' > $PROGMEM.chr
|
cat $PROGMEM.hex | sed 's/ /\t/;s/ /\t /;s/ /\\x/g;s/\t/ /g' > $PROGMEM.chr
|
||||||
|
|
||||||
|
|
||||||
# (8)
|
# (8)
|
||||||
#convert $PROGMEM.chr to $PROGMEM.var (convert data to text)
|
#convert $PROGMEM.chr to $PROGMEM.var (convert data to text, TODO: rewrite as awk script)
|
||||||
echo " progmem.sh (8) - converting string data" >&2
|
echo " progmem.sh (8) - converting string data" >&2
|
||||||
cat $PROGMEM.chr | \
|
cat $PROGMEM.chr | \
|
||||||
sed 's/ \\xff\\xff/ /;' | \
|
sed 's/ \\xff\\xff/ /;' | \
|
||||||
|
@ -121,8 +122,10 @@ cat $PROGMEM.chr | \
|
||||||
sed 's/\\x1b/\\\\\\x1b/g;' | \
|
sed 's/\\x1b/\\\\\\x1b/g;' | \
|
||||||
sed 's/\\x01/\\\\\\x01/g;' | \
|
sed 's/\\x01/\\\\\\x01/g;' | \
|
||||||
sed 's/\\xf8/\\\\\\xf8/g;' | \
|
sed 's/\\xf8/\\\\\\xf8/g;' | \
|
||||||
sed 's/\\x00$/\\x0a/;s/^/printf "/;s/$/"/' | sh > $PROGMEM.var
|
sed 's/\\x00$//;s/^/echo -e "/;s/$/"/' | sh > $PROGMEM.var
|
||||||
cat $PROGMEM.var | sed 's/\r/\n/g' |sed -E 's/^[0-9a-f]{8} [^ ]* //' >$PROGMEM.txt
|
|
||||||
|
#this step can be omitted because .txt file is not used
|
||||||
|
#cat $PROGMEM.var | sed 's/\r/\n/g' |sed -E 's/^[0-9a-f]{8} [^ ]* //' >$PROGMEM.txt
|
||||||
|
|
||||||
echo "progmem.sh finished" >&2
|
echo "progmem.sh finished" >&2
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue