Merge pull request #847 from XPila/MK3-new_lang

Mk3 new lang
This commit is contained in:
XPila 2018-06-18 14:55:23 +02:00 committed by GitHub
commit 4a2b94afbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 136 additions and 107 deletions

View File

@ -27,23 +27,6 @@
#endif //TMC2130 #endif //TMC2130
#include <stdarg.h>
int lcd_puts_P(const char* str)
{
return fputs_P(str, lcdout);
}
int lcd_printf_P(const char* format, ...)
{
va_list args;
va_start(args, format);
int ret = vfprintf_P(lcdout, format, args);
va_end(args);
return ret;
}
int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */ int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
extern int lcd_change_fil_state; extern int lcd_change_fil_state;
@ -315,7 +298,6 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
#endif #endif
#endif #endif
/* Helper macros for menus */ /* Helper macros for menus */
#define START_MENU() do { \ #define START_MENU() do { \
if (encoderPosition > 0x8000) encoderPosition = 0; \ if (encoderPosition > 0x8000) encoderPosition = 0; \
@ -427,6 +409,48 @@ static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder = 0, const boo
/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */ /* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */
#include <stdarg.h>
int lcd_puts_P(const char* str)
{
return fputs_P(str, lcdout);
}
int lcd_printf_P(const char* format, ...)
{
va_list args;
va_start(args, format);
int ret = vfprintf_P(lcdout, format, args);
va_end(args);
return ret;
}
#ifdef DEBUG_MENU_PRINTF_TEST
int menu_item_printf_P(uint8_t& item, uint8_t line, const char* format, ...)
{
va_list args;
va_start(args, format);
int ret = 0;
if (item == line)
{
if (lcdDrawUpdate)
{
//ret =
lcd.setCursor(0, line);
lcd.print(' ');
int cnt = vfprintf_P(lcdout, format, args);
for (int i = cnt; i < 19; i++)
lcd.print(' ');
lcd.print('>');
}
}
item++;
va_end(args);
return ret;
}
#endif //DEBUG_MENU_PRINTF_TEST
static void lcd_status_screen() static void lcd_status_screen()
{ {
if (firstrun == 1) if (firstrun == 1)
@ -5589,6 +5613,10 @@ static void lcd_main_menu()
MENU_ITEM(submenu, _i("Support"), lcd_support_menu);////MSG_SUPPORT c=0 r=0 MENU_ITEM(submenu, _i("Support"), lcd_support_menu);////MSG_SUPPORT c=0 r=0
MENU_ITEM(submenu, _i("W25x20XL init"), lcd_test_menu);////MSG_SUPPORT c=0 r=0 MENU_ITEM(submenu, _i("W25x20XL init"), lcd_test_menu);////MSG_SUPPORT c=0 r=0
#ifdef DEBUG_MENU_PRINTF_TEST
menu_item_printf_P(_menuItemNr, _lineNr, _N("Test %d %d %d"), 0, 1, 2);
#endif //DEBUG_MENU_PRINTF_TEST
END_MENU(); END_MENU();
} }

View File

@ -149,6 +149,7 @@
//#define DEBUG_BUILD //#define DEBUG_BUILD
//#define DEBUG_SEC_LANG //secondary language debug output at startup //#define DEBUG_SEC_LANG //secondary language debug output at startup
//#define DEBUG_W25X20CL //debug external spi flash //#define DEBUG_W25X20CL //debug external spi flash
//#define DEBUG_MENU_PRINTF_TEST
#ifdef DEBUG_BUILD #ifdef DEBUG_BUILD
//#define _NO_ASM //#define _NO_ASM
#define DEBUG_DCODES //D codes #define DEBUG_DCODES //D codes

View File

@ -5,18 +5,18 @@
# #
# Input files: # Input files:
# lang_en.txt # lang_en.txt
# lang_en_$LANG.txt # lang_en_xx.txt
# #
# Output files: # Output files:
# lang_en.tmp (temporary, will be removed when finished) # lang_en.tmp (temporary, will be removed when finished)
# lang_en_$LANG.tmp ==||== # lang_en_xx.tmp ==||==
# lang_en_$LANG.dif ==||== # lang_en_xx.dif ==||==
# lang_$LANG.txt # lang_xx.txt
# #
# #
# Selected language: # Selected language:
LANG=$1 LNG=$1
if [ -z "$LANG" ]; then LANG='cz'; fi if [ -z "$LNG" ]; then LNG='cz'; fi
# #
# #
@ -24,8 +24,8 @@ finish()
{ {
if [ $1 -eq 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_$LNG.tmp ]; then rm lang_en_$LNG.tmp; fi
if [ -e lang_en_$LANG.dif ]; then rm lang_en_$LANG.dif; fi if [ -e lang_en_$LNG.dif ]; then rm lang_en_$LNG.dif; fi
fi fi
# echo >&2 # echo >&2
if [ $1 -eq 0 ]; then if [ $1 -eq 0 ]; then
@ -38,59 +38,59 @@ finish()
make_lang() make_lang()
{ {
LANG=$1 LNG=$1
echo "make_lang.sh started" >&2 echo "make_lang.sh started" >&2
echo "selected language=$LANG" >&2 echo "selected language=$LNG" >&2
#check if input files exists #check if input files exists
echo -n " checking input files..." >&2 echo -n " checking input files..." >&2
if [ ! -e lang_en.txt ]; then echo "NG! file lang_en.txt not found!" >&2; exit 1; fi if [ ! -e lang_en.txt ]; then echo "NG! file lang_en.txt not found!" >&2; exit 1; fi
if [ ! -e lang_en_$LANG.txt ]; then echo "NG! file lang_en_$LANG.txt not found!" >&2; exit 1; fi if [ ! -e lang_en_$LNG.txt ]; then echo "NG! file lang_en_$LNG.txt not found!" >&2; exit 1; fi
echo "OK" >&2 echo "OK" >&2
#filter comment and empty lines from key and dictionary files, create temporary files #filter comment and empty lines from key and dictionary files, create temporary files
echo -n " creating tmp files..." >&2 echo -n " creating tmp files..." >&2
cat lang_en.txt | sed "/^$/d;/^#/d" > lang_en.tmp cat lang_en.txt | sed "/^$/d;/^#/d" > lang_en.tmp
cat lang_en_$LANG.txt | sed "/^$/d;/^#/d" > lang_en_$LANG.tmp cat lang_en_$LNG.txt | sed "/^$/d;/^#/d" > lang_en_$LNG.tmp
echo "OK" >&2 echo "OK" >&2
#cat lang_en_$LANG.tmp | sed 'n;d' >test1.txt #cat lang_en_$LNG.tmp | sed 'n;d' >test1.txt
#compare files using diff and check for differences #compare files using diff and check for differences
echo -n " comparing tmp files..." >&2 echo -n " comparing tmp files..." >&2
if ! cat lang_en_$LANG.tmp | sed 'n;d' | diff lang_en.tmp - > lang_en_$LANG.dif; then if ! cat lang_en_$LNG.tmp | sed 'n;d' | diff lang_en.tmp - > lang_en_$LNG.dif; then
echo "NG!" >&2 echo "NG!" >&2
echo "Entries in lang_en_$LANG.txt are different from lang_en.txt!" >&2 echo "Entries in lang_en_$LNG.txt are different from lang_en.txt!" >&2
echo "please check lang_en_$LANG.dif" >&2 echo "please check lang_en_$LNG.dif" >&2
finish 1 finish 1
fi fi
echo "OK" >&2 echo "OK" >&2
#generate lang_xx.txt (secondary language text data sorted by ids) #generate lang_xx.txt (secondary language text data sorted by ids)
echo -n " generating lang_$LANG.txt..." >&2 echo -n " generating lang_$LNG.txt..." >&2
cat lang_en_$LANG.tmp | sed '1~2d' | sed "s/^\"\\\\x00/\"/" > lang_$LANG.txt cat lang_en_$LNG.tmp | sed '1~2d' | sed "s/^\"\\\\x00/\"/" > lang_$LNG.txt
echo "OK" >&2 echo "OK" >&2
#generate lang_xx.dat (secondary language text data in binary form) #generate lang_xx.dat (secondary language text data in binary form)
echo -n " generating lang_$LANG.dat..." >&2 echo -n " generating lang_$LNG.dat..." >&2
cat lang_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do cat lang_$LNG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do
s=${s#\"} s=${s#\"}
s=${s%\"} s=${s%\"}
/bin/echo -e -n "$s\x00" /bin/echo -e -n "$s\x00"
done >lang_$LANG.dat done >lang_$LNG.dat
echo "OK" >&2 echo "OK" >&2
#calculate variables #calculate variables
lt_magic='\xa5\x5a\xb4\x4b' lt_magic='\xa5\x5a\xb4\x4b'
lt_count=$(grep -c '^' lang_$LANG.txt) lt_count=$(grep -c '^' lang_$LNG.txt)
lt_data_size=$(wc -c lang_$LANG.dat | cut -f1 -d' ') lt_data_size=$(wc -c lang_$LNG.dat | cut -f1 -d' ')
lt_offs_size=$((2 * $lt_count)) lt_offs_size=$((2 * $lt_count))
lt_size=$((16 + $lt_offs_size + $lt_data_size)) lt_size=$((16 + $lt_offs_size + $lt_data_size))
lt_chsum=0 lt_chsum=0
lt_code='\xff\xff' lt_code='\xff\xff'
lt_resv1='\xff\xff\xff\xff' lt_resv1='\xff\xff\xff\xff'
case "$LANG" in case "$LNG" in
*en*) lt_code='\x6e\x65' ;; *en*) lt_code='\x6e\x65' ;;
*cz*) lt_code='\x73\x63' ;; *cz*) lt_code='\x73\x63' ;;
*de*) lt_code='\x65\x64' ;; *de*) lt_code='\x65\x64' ;;
@ -100,15 +100,15 @@ case "$LANG" in
esac esac
#generate lang_xx.ofs (secondary language text data offset table) #generate lang_xx.ofs (secondary language text data offset table)
echo -n " generating lang_$LANG.ofs..." >&2 echo -n " generating lang_$LNG.ofs..." >&2
cat lang_$LANG.txt | sed "s/\\\\x[0-9a-f][0-9a-f]/\./g;s/\\\\[0-7][0-7][0-7]/\./g" |\ cat lang_$LNG.txt | sed "s/\\\\x[0-9a-f][0-9a-f]/\./g;s/\\\\[0-7][0-7][0-7]/\./g" |\
awk 'BEGIN { o='$((16 + $lt_offs_size))';} { printf("%d\n",o); o+=(length($0)-1); }' > lang_$LANG.ofs awk 'BEGIN { o='$((16 + $lt_offs_size))';} { printf("%d\n",o); o+=(length($0)-1); }' > lang_$LNG.ofs
echo "OK" >&2 echo "OK" >&2
#generate lang_xx.bin (secondary language result binary file) #generate lang_xx.bin (secondary language result binary file)
echo " generating lang_$LANG.bin:" >&2 echo " generating lang_$LNG.bin:" >&2
#create empty file #create empty file
dd if=/dev/zero of=lang_$LANG.bin bs=1 count=$lt_size 2>/dev/null dd if=/dev/zero of=lang_$LNG.bin bs=1 count=$lt_size 2>/dev/null
#awk code to format ui16 variables for dd #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); }' awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }'
@ -116,32 +116,32 @@ awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }'
echo -n " writing header (16 bytes)..." >&2 echo -n " writing header (16 bytes)..." >&2
/bin/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_$LNG.bin bs=1 count=4 seek=0 conv=notrunc 2>/dev/null
/bin/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_$LNG.bin bs=1 count=2 seek=4 conv=notrunc 2>/dev/null
/bin/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_$LNG.bin bs=1 count=2 seek=6 conv=notrunc 2>/dev/null
/bin/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_$LNG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
/bin/echo -n -e "$lt_code" |\ /bin/echo -n -e "$lt_code" |\
dd of=lang_$LANG.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null dd of=lang_$LNG.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null
/bin/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_$LNG.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
/bin/echo -n -e $(cat lang_$LANG.ofs | awk "$awk_ui16" | tr -d '\n'; echo) |\ /bin/echo -n -e $(cat lang_$LNG.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_$LNG.bin bs=1 count=$lt_offs_size seek=16 conv=notrunc 2>/dev/null
echo "OK" >&2 echo "OK" >&2
echo -n " writing text data ($lt_data_size bytes)..." >&2 echo -n " writing text data ($lt_data_size bytes)..." >&2
dd if=./lang_$LANG.dat of=./lang_$LANG.bin bs=1 count=$lt_data_size seek=$((16 + $lt_offs_size)) conv=notrunc 2>/dev/null dd if=./lang_$LNG.dat of=./lang_$LNG.bin bs=1 count=$lt_data_size seek=$((16 + $lt_offs_size)) conv=notrunc 2>/dev/null
echo "OK" >&2 echo "OK" >&2
#calculate and update checksum #calculate and update checksum
lt_chsum=$(cat lang_$LANG.bin | xxd | cut -c11-49 | tr ' ' "\n" | sed '/^$/d' | awk 'BEGIN { sum = 0; } { sum += strtonum("0x"$1); if (sum > 0xffff) sum -= 0x10000; } END { printf("%x\n", sum); }') lt_chsum=$(cat lang_$LNG.bin | xxd | cut -c11-49 | tr ' ' "\n" | sed '/^$/d' | awk 'BEGIN { sum = 0; } { sum += strtonum("0x"$1); if (sum > 0xffff) sum -= 0x10000; } END { printf("%x\n", sum); }')
/bin/echo -n -e $(echo -n $((0x$lt_chsum)) | awk "$awk_ui16") |\ /bin/echo -n -e $(echo -n $((0x$lt_chsum)) | awk "$awk_ui16") |\
dd of=lang_$LANG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null dd of=lang_$LNG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
echo " lang_table details:" >&2 echo " lang_table details:" >&2
echo " lt_count = $lt_count" >&2 echo " lt_count = $lt_count" >&2
@ -149,9 +149,9 @@ echo " lt_size = $lt_size" >&2
echo " lt_chsum = $lt_chsum" >&2 echo " lt_chsum = $lt_chsum" >&2
} }
echo $LANG echo $LNG
if [ "$LANG" = "all" ]; then if [ "$LNG" = "all" ]; then
make_lang cz make_lang cz
make_lang de make_lang de
make_lang es make_lang es
@ -159,7 +159,7 @@ if [ "$LANG" = "all" ]; then
make_lang pl make_lang pl
exit 0 exit 0
else else
make_lang $LANG make_lang $LNG
fi fi
finish 0 finish 0

View File

@ -5,11 +5,11 @@
# #
SRCDIR="../../Firmware" SRCDIR="../../Firmware"
# #
LANG=$1 LNG=$1
if [ -z "$LANG" ]; then LANG=cz; fi if [ -z "$LNG" ]; then LNG=cz; fi
# #
if [ "$LANG" == "all" ]; then if [ "$LNG" == "all" ]; then
./make_po.sh cz ./make_po.sh cz
./make_po.sh de ./make_po.sh de
./make_po.sh es ./make_po.sh es
@ -19,13 +19,13 @@ if [ "$LANG" == "all" ]; then
fi fi
echo "make_po.sh started" >&2 echo "make_po.sh started" >&2
echo " selected language=$LANG" >&2 echo " selected language=$LNG" >&2
#remove output file if exists #remove output file if exists
if [ -e lang_$LANG.po ]; then rm lang_$LANG.po; fi if [ -e lang_$LNG.po ]; then rm lang_$LNG.po; fi
lang_name=$(\ lang_name=$(\
case "$LANG" in case "$LNG" in
*en*) echo "English" ;; *en*) echo "English" ;;
*cz*) echo "Czech" ;; *cz*) echo "Czech" ;;
*de*) echo "German" ;; *de*) echo "German" ;;
@ -35,7 +35,7 @@ lang_name=$(\
esac) esac)
lang_short=$(\ lang_short=$(\
case "$LANG" in case "$LNG" in
*en*) echo "en" ;; *en*) echo "en" ;;
*cz*) echo "cs" ;; *cz*) echo "cs" ;;
*de*) echo "de" ;; *de*) echo "de" ;;
@ -47,29 +47,29 @@ lang_short=$(\
po_date=$(date) po_date=$(date)
#write po header #write po header
echo "# Translation of Prusa-Firmware into $lang_name." > lang_$LANG.po echo "# Translation of Prusa-Firmware into $lang_name." > lang_$LNG.po
echo "#" >> lang_$LANG.po echo "#" >> lang_$LNG.po
echo 'msgid ""' >> lang_$LANG.po echo 'msgid ""' >> lang_$LNG.po
echo 'msgstr ""' >> lang_$LANG.po echo 'msgstr ""' >> lang_$LNG.po
echo '"MIME-Version: 1.0\n"' >> lang_$LANG.po echo '"MIME-Version: 1.0\n"' >> lang_$LNG.po
echo '"Content-Type: text/plain; charset=UTF-8\n"' >> lang_$LANG.po echo '"Content-Type: text/plain; charset=UTF-8\n"' >> lang_$LNG.po
echo '"Content-Transfer-Encoding: 8bit\n"' >> lang_$LANG.po echo '"Content-Transfer-Encoding: 8bit\n"' >> lang_$LNG.po
echo '"Language: '$lang_short'\n"' >> lang_$LANG.po echo '"Language: '$lang_short'\n"' >> lang_$LNG.po
echo '"Project-Id-Version: Prusa-Firmware\n"' >> lang_$LANG.po echo '"Project-Id-Version: Prusa-Firmware\n"' >> lang_$LNG.po
echo '"POT-Creation-Date: '$po_date'\n"' >> lang_$LANG.po echo '"POT-Creation-Date: '$po_date'\n"' >> lang_$LNG.po
echo '"PO-Revision-Date: '$po_date'\n"' >> lang_$LANG.po echo '"PO-Revision-Date: '$po_date'\n"' >> lang_$LNG.po
echo '"Language-Team: \n"' >> lang_$LANG.po echo '"Language-Team: \n"' >> lang_$LNG.po
echo '"X-Generator: Poedit 2.0.7\n"' >> lang_$LANG.po echo '"X-Generator: Poedit 2.0.7\n"' >> lang_$LNG.po
echo '"X-Poedit-SourceCharset: UTF-8\n"' >> lang_$LANG.po echo '"X-Poedit-SourceCharset: UTF-8\n"' >> lang_$LNG.po
echo '"Last-Translator: \n"' >> lang_$LANG.po echo '"Last-Translator: \n"' >> lang_$LNG.po
echo '"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"' >> lang_$LANG.po echo '"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"' >> lang_$LNG.po
echo >> lang_$LANG.po echo >> lang_$LNG.po
#list .cpp, .c and .h files #list .cpp, .c and .h files
files=$(ls "$SRCDIR"/*.cpp "$SRCDIR"/*.c "$SRCDIR"/*.h) files=$(ls "$SRCDIR"/*.cpp "$SRCDIR"/*.c "$SRCDIR"/*.h)
num_texts=$(grep '^#' -c ../lang_en_$LANG.txt) num_texts=$(grep '^#' -c ../lang_en_$LNG.txt)
num_texts_nt=$(grep '^\"\\x00\"' -c ../lang_en_$LANG.txt) num_texts_nt=$(grep '^\"\\x00\"' -c ../lang_en_$LNG.txt)
echo " $num_texts texts, $num_texts_nt not translated" >&2 echo " $num_texts texts, $num_texts_nt not translated" >&2
#loop over all messages #loop over all messages
@ -77,7 +77,7 @@ s0=''
s1='' s1=''
s2='' s2=''
num=1 num=1
cat ../lang_en_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read -r s; do cat ../lang_en_$LNG.txt | sed "s/\\\\/\\\\\\\\/g" | while read -r s; do
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
@ -103,11 +103,11 @@ cat ../lang_en_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read -r s; do
s2=$s1 s2=$s1
s1=$s0 s1=$s0
s0=$s s0=$s
done >> lang_$LANG.po done >> lang_$LNG.po
#replace LF with CRLF #replace LF with CRLF
sync sync
sed -i 's/$/\r/' lang_$LANG.po sed -i 's/$/\r/' lang_$LNG.po
echo "make_po.sh finished" >&2 echo "make_po.sh finished" >&2
#read #read

View File

@ -2,14 +2,14 @@
# #
# #
LANG=$1 LNG=$1
if [ -z "$LANG" ]; then exit -1; fi if [ -z "$LNG" ]; then exit -1; fi
#convert '\\e' sequencies to 'x1b' and '\\' to '\' #convert '\\e' sequencies to 'x1b' and '\\' to '\'
cat $LANG.po | sed 's/\\\\e/\\x1b/g;s/\\\\/\\/g' > $LANG'_filtered.po' cat $LNG.po | sed 's/\\\\e/\\x1b/g;s/\\\\/\\/g' > $LNG'_filtered.po'
#join lines with multi-line string constants #join lines with multi-line string constants
cat $LANG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LANG'_new.po' cat $LNG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LNG'_new.po'
#generate dictionary #generate dictionary
cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do
@ -17,7 +17,7 @@ cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do
if [ "${s:0:1}" = "\"" ]; then if [ "${s:0:1}" = "\"" ]; then
# /bin/echo -e "$s" # /bin/echo -e "$s"
s=$(/bin/echo -e "$s") s=$(/bin/echo -e "$s")
s2=$(grep -F -A1 -B0 "$s" "$LANG"_new.po | tail -n1 | sed 's/^msgstr //') s2=$(grep -F -A1 -B0 "$s" "$LNG"_new.po | tail -n1 | sed 's/^msgstr //')
if [ -z "$s2" ]; then if [ -z "$s2" ]; then
echo '"\x00"' echo '"\x00"'
else else
@ -25,4 +25,4 @@ cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do
fi fi
# echo # echo
fi fi
done > lang_en_$LANG.txt done > lang_en_$LNG.txt

View File

@ -23,8 +23,8 @@ 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 "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
# #
# Selected language: # Selected language:
LANG=$1 LNG=$1
#if [ -z "$LANG" ]; then LANG='cz'; fi #if [ -z "$LNG" ]; then LNG='cz'; fi
# #
# Params: # Params:
IGNORE_MISSING_TEXT=1 IGNORE_MISSING_TEXT=1
@ -99,8 +99,8 @@ 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 "$LANG" ]; then if [ ! -z "$LNG" ]; then
./update_lang.sh $LANG 2>./update_lang.out ./update_lang.sh $LNG 2>./update_lang.out
if [ $? -ne 0 ]; then echo "NG! - check update_lang.out file" >&2; finish 1; fi if [ $? -ne 0 ]; then echo "NG! - check update_lang.out file" >&2; finish 1; fi
echo "OK" >&2 echo "OK" >&2
finish 0 finish 0

View File

@ -9,8 +9,8 @@ if [ -z "$OBJCOPY" ]; then echo 'variable OBJCOPY not set!' >&2; exit 1; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
# #
# Selected language: # Selected language:
LANG=$1 LNG=$1
if [ -z "$LANG" ]; then LANG='cz'; fi if [ -z "$LNG" ]; then LNG='cz'; fi
# #
finish() finish()
@ -28,11 +28,11 @@ finish()
} }
echo "update_lang.sh started" >&2 echo "update_lang.sh started" >&2
echo " selected language=$LANG" >&2 echo " selected language=$LNG" >&2
echo -n " checking files..." >&2 echo -n " checking files..." >&2
if [ ! -e text.sym ]; then echo "NG! file text.sym not found!" >&2; finish 1; fi if [ ! -e text.sym ]; then echo "NG! file text.sym not found!" >&2; finish 1; fi
if [ ! -e lang_$LANG.bin ]; then echo "NG! file lang_$LANG.bin not found!" >&2; finish 1; fi if [ ! -e lang_$LNG.bin ]; then echo "NG! file lang_$LNG.bin not found!" >&2; finish 1; fi
if [ ! -e firmware.bin ]; then echo "NG! file firmware.bin not found!" >&2; finish 1; fi if [ ! -e firmware.bin ]; then echo "NG! file firmware.bin not found!" >&2; finish 1; fi
echo "OK" >&2 echo "OK" >&2
@ -62,17 +62,17 @@ lang_table_size=$((256*$((($sec_lang_size - ($lang_table_addr - $sec_lang_addr))
printf " lang_table_size =0x%04x (=%d bytes)\n" $lang_table_size $lang_table_size >&2 printf " lang_table_size =0x%04x (=%d bytes)\n" $lang_table_size $lang_table_size >&2
#get lang_xx.bin file size #get lang_xx.bin file size
lang_file_size=$(wc -c lang_$LANG.bin | cut -f1 -d' ') lang_file_size=$(wc -c lang_$LNG.bin | cut -f1 -d' ')
printf " lang_file_size =0x%04x (=%d bytes)\n" $lang_file_size $lang_file_size >&2 printf " lang_file_size =0x%04x (=%d bytes)\n" $lang_file_size $lang_file_size >&2
if [ $lang_file_size -gt $lang_table_size ]; then echo "Lanaguage binary file size too big!" >&2; finish 1; fi if [ $lang_file_size -gt $lang_table_size ]; then echo "Lanaguage binary file size too big!" >&2; finish 1; fi
echo "updating 'firmware.bin'..." >&2 echo "updating 'firmware.bin'..." >&2
dd if=lang_$LANG.bin of=firmware.bin bs=1 seek=$lang_table_addr conv=notrunc 2>/dev/null dd if=lang_$LNG.bin of=firmware.bin bs=1 seek=$lang_table_addr conv=notrunc 2>/dev/null
#convert bin to hex #convert bin to hex
echo "converting to hex..." >&2 echo "converting to hex..." >&2
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware_$LANG.hex $OBJCOPY -I binary -O ihex ./firmware.bin ./firmware_$LNG.hex
finish 0 finish 0