lang-add: add a *crude* metadata extractor
This commit is contained in:
parent
a07b7291b4
commit
b9ca45fea1
1 changed files with 17 additions and 6 deletions
|
@ -26,6 +26,7 @@ echo "fw-clean languages:$LANGUAGES" >&2
|
||||||
|
|
||||||
# insert single text to english dictionary
|
# insert single text to english dictionary
|
||||||
# $1 - text to insert
|
# $1 - text to insert
|
||||||
|
# $2 - metadata
|
||||||
insert_en()
|
insert_en()
|
||||||
{
|
{
|
||||||
#replace '[' and ']' in string with '\[' and '\]'
|
#replace '[' and ']' in string with '\[' and '\]'
|
||||||
|
@ -38,12 +39,13 @@ insert_en()
|
||||||
# insert new text
|
# insert new text
|
||||||
sed -i "$ln"'i\\' lang_en.txt
|
sed -i "$ln"'i\\' lang_en.txt
|
||||||
sed -i "$ln"'i\'"$1"'\' lang_en.txt
|
sed -i "$ln"'i\'"$1"'\' lang_en.txt
|
||||||
sed -i "$ln"'i\#\' lang_en.txt
|
sed -i "${ln}i\\#$2" lang_en.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
# insert single text to translated dictionary
|
# insert single text to translated dictionary
|
||||||
# $1 - text to insert
|
# $1 - text to insert
|
||||||
# $2 - sufix
|
# $2 - suffix
|
||||||
|
# $3 - metadata
|
||||||
insert_xx()
|
insert_xx()
|
||||||
{
|
{
|
||||||
#replace '[' and ']' in string with '\[' and '\]'
|
#replace '[' and ']' in string with '\[' and '\]'
|
||||||
|
@ -57,7 +59,15 @@ insert_xx()
|
||||||
sed -i "$ln"'i\\' lang_en_$2.txt
|
sed -i "$ln"'i\\' lang_en_$2.txt
|
||||||
sed -i "$ln"'i\"\x00"\' lang_en_$2.txt
|
sed -i "$ln"'i\"\x00"\' lang_en_$2.txt
|
||||||
sed -i "$ln"'i\'"$1"'\' lang_en_$2.txt
|
sed -i "$ln"'i\'"$1"'\' lang_en_$2.txt
|
||||||
sed -i "$ln"'i\#\' lang_en_$2.txt
|
sed -i "${ln}i\\#$3" lang_en_$2.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
# find the metadata for the specified string
|
||||||
|
# TODO: this is unbeliveably crude
|
||||||
|
# $1 - text to search for
|
||||||
|
find_metadata()
|
||||||
|
{
|
||||||
|
sed -ne "s^.*\(_[iI]\|ISTR\)($1).*////\(.*\)^\2^p" ../Firmware/*.[ch]* | head -1
|
||||||
}
|
}
|
||||||
|
|
||||||
# check if input file exists
|
# check if input file exists
|
||||||
|
@ -72,13 +82,14 @@ cat lang_add.txt | sed 's/^/"/;s/$/"/' | while read new_s; do
|
||||||
echo "$new_s"
|
echo "$new_s"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
|
meta=$(find_metadata "$new_s")
|
||||||
echo "adding text:"
|
echo "adding text:"
|
||||||
echo "$new_s"
|
echo "$new_s ($meta)"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
insert_en "$new_s"
|
insert_en "$new_s" "$meta"
|
||||||
for lang in $LANGUAGES; do
|
for lang in $LANGUAGES; do
|
||||||
insert_xx "$new_s" "$lang"
|
insert_xx "$new_s" "$lang" "$meta"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Reference in a new issue