From 1f4da80609a9ebe6c87c4f4e434df1b0c3b9e5a0 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Fri, 11 Mar 2022 15:35:30 +0100 Subject: [PATCH] Fix `\0x Refresh` and `Sheet..` messages being added correctly --- lang/lang-add.sh | 13 +++++++------ lang/progmem.sh | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lang/lang-add.sh b/lang/lang-add.sh index 3d26a2d9..04d3d19d 100755 --- a/lang/lang-add.sh +++ b/lang/lang-add.sh @@ -21,8 +21,8 @@ if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit if [ ! -z "$COMMUNITY_LANGUAGES" ]; then LANGUAGES+=" $COMMUNITY_LANGUAGES" fi -echo "fw-clean languages:$LANGUAGES" >&2 - +LANGUAGES=$(ls lang_en_*.txt|cut -d '_' -f3|cut -d '.' -f1) +echo "lang-add languages:$LANGUAGES" >&2 # insert single text to english dictionary # $1 - text to insert @@ -30,7 +30,7 @@ echo "fw-clean languages:$LANGUAGES" >&2 insert_en() { #replace '[' and ']' in string with '\[' and '\]' - str=$(echo "$1" | sed "s/\[/\\\[/g;s/\]/\\\]/g") + str=$(echo "$1" | sed 's/\[/\\\[/g;s/\]/\\\]/g') # extract english texts, merge new text, grep line number ln=$((cat lang_en.txt; echo "$1") | sed "/^$/d;/^#/d" | sort | grep -n "$str" | sed "s/:.*//;q") # calculate position for insertion @@ -49,7 +49,7 @@ insert_en() insert_xx() { #replace '[' and ']' in string with '\[' and '\]' - str=$(echo "$1" | sed "s/\[/\\\[/g;s/\]/\\\]/g") + str=$(echo "$1" | sed 's/\[/\\\[/g;s/\]/\\\]/g') # extract english texts, merge new text, grep line number ln=$((cat lang_en_$2.txt; echo "$1") | sed "/^$/d;/^#/d" | sed -n 'p;n' | sort | grep -n "$str" | sed "s/:.*//;q") # calculate position for insertion @@ -67,7 +67,8 @@ insert_xx() # $1 - text to search for find_metadata() { - sed -ne "s^.*\(_[iI]\|ISTR\)($1).*////\(.*\)^\2^p" ../Firmware/*.[ch]* | head -1 + FIND_STR=$(echo $1|sed 's/\\/\\\\/g;s/\\\\x0a/\\\\n/g') + sed -ne "s^.*\(_[iI]\|ISTR\)($FIND_STR).*////\(.*\)^\2^p" ../Firmware/*.[ch]* | head -1 } # check if input file exists @@ -76,7 +77,7 @@ if ! [ -e lang_add.txt ]; then exit 1 fi -cat lang_add.txt | sed 's/^/"/;s/$/"/' | while read new_s; do +cat lang_add.txt | sed 's/^/"/;s/$/"/;s/\\/\\\\/g' | while read new_s; do if grep "$new_s" lang_en.txt >/dev/null; then echo "text already exist:" echo "$new_s" diff --git a/lang/progmem.sh b/lang/progmem.sh index ba8d1f40..6f99995f 100755 --- a/lang/progmem.sh +++ b/lang/progmem.sh @@ -115,6 +115,9 @@ cat $PROGMEM.chr | \ sed 's/\\x01/\\\\\\x01/g;' | \ sed 's/\\xf8/\\\\\\xf8/g;' | \ sed 's/\\x0a/\\\\\\x0a/g;' | \ + sed 's/\\x04/\\\\\\x04/g;' | \ + sed 's/\\xe4/\\\\\\xe4/g;' | \ + sed 's/\\n/\\\\\\0a/g;' | \ sed 's/\\x00$/\n/;s/^/\"/;s/$/\"\\/'; \ ) | sh > $PROGMEM.var