New ML support - fixed po generator script make_po.sh
+regenerated po files (complete, tested in poedit) +update_lang.sh - cosmetics
This commit is contained in:
parent
4b9ec286db
commit
6f362974ef
7 changed files with 7321 additions and 1245 deletions
1426
lang/po/lang_cz.po
1426
lang/po/lang_cz.po
File diff suppressed because it is too large
Load diff
1756
lang/po/lang_de.po
1756
lang/po/lang_de.po
File diff suppressed because it is too large
Load diff
1796
lang/po/lang_es.po
1796
lang/po/lang_es.po
File diff suppressed because it is too large
Load diff
1771
lang/po/lang_it.po
1771
lang/po/lang_it.po
File diff suppressed because it is too large
Load diff
1756
lang/po/lang_pl.po
1756
lang/po/lang_pl.po
File diff suppressed because it is too large
Load diff
|
@ -9,12 +9,22 @@ LANG=$1
|
|||
if [ -z "$LANG" ]; then LANG=cz; fi
|
||||
#
|
||||
|
||||
if [ "$LANG" == "all" ]; then
|
||||
./make_po.sh cz
|
||||
./make_po.sh de
|
||||
./make_po.sh es
|
||||
./make_po.sh it
|
||||
./make_po.sh pl
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "make_po.sh started" >&2
|
||||
echo " selected language=$LANG" >&2
|
||||
|
||||
#remove output file if exists
|
||||
if [ -e lang_$LANG.po ]; then rm lang_$LANG.po; fi
|
||||
|
||||
langname=$(\
|
||||
lang_name=$(\
|
||||
case "$LANG" in
|
||||
*en*) echo "English" ;;
|
||||
*cz*) echo "Czech" ;;
|
||||
|
@ -24,38 +34,79 @@ langname=$(\
|
|||
*pl*) echo "Polish" ;;
|
||||
esac)
|
||||
|
||||
lang_short=$(\
|
||||
case "$LANG" in
|
||||
*en*) echo "en" ;;
|
||||
*cz*) echo "cs" ;;
|
||||
*de*) echo "de" ;;
|
||||
*it*) echo "it" ;;
|
||||
*es*) echo "es" ;;
|
||||
*pl*) echo "pl" ;;
|
||||
esac)
|
||||
|
||||
po_date=$(date)
|
||||
|
||||
#write po header
|
||||
echo "# Translation into $langname." > lang_$LANG.po
|
||||
echo "# Translation of Prusa-Firmware into $lang_name." > lang_$LANG.po
|
||||
echo "#" >> lang_$LANG.po
|
||||
echo 'msgid ""' >> lang_$LANG.po
|
||||
echo 'msgstr ""' >> lang_$LANG.po
|
||||
echo '"MIME-Version: 1.0\n"' >> lang_$LANG.po
|
||||
echo '"Content-Type: text/plain; charset=UTF-8\n"' >> lang_$LANG.po
|
||||
echo '"Content-Transfer-Encoding: 8bit\n"' >> lang_$LANG.po
|
||||
echo '"Language: '$lang_short'\n"' >> lang_$LANG.po
|
||||
echo '"Project-Id-Version: Prusa-Firmware\n"' >> lang_$LANG.po
|
||||
echo '"POT-Creation-Date: '$po_date'\n"' >> lang_$LANG.po
|
||||
echo '"PO-Revision-Date: '$po_date'\n"' >> lang_$LANG.po
|
||||
echo '"Language-Team: \n"' >> lang_$LANG.po
|
||||
echo '"X-Generator: Poedit 2.0.7\n"' >> lang_$LANG.po
|
||||
echo '"X-Poedit-SourceCharset: UTF-8\n"' >> lang_$LANG.po
|
||||
echo '"Last-Translator: \n"' >> lang_$LANG.po
|
||||
echo '"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"' >> lang_$LANG.po
|
||||
echo >> lang_$LANG.po
|
||||
|
||||
#list .cpp, .c and .h files
|
||||
files=$(ls "$SRCDIR"/*.cpp "$SRCDIR"/*.c "$SRCDIR"/*.h)
|
||||
|
||||
#loop over all messages, print only untranslated (=="\x00")
|
||||
num_texts=$(grep '^#' -c ../lang_en_$LANG.txt)
|
||||
num_texts_nt=$(grep '^\"\\x00\"' -c ../lang_en_$LANG.txt)
|
||||
echo " $num_texts texts, $num_texts_nt not translated" >&2
|
||||
|
||||
#loop over all messages
|
||||
s0=''
|
||||
s1=''
|
||||
s2=''
|
||||
num=1
|
||||
cat ../lang_en_$LANG.txt | sed "s/\\\\/\\\\\\\\/g;s/^#/#: /" | while read -r s; do
|
||||
if [ "$s" == "" ]; then
|
||||
echo " processing $num of $num_texts" >&2
|
||||
if [ "$s0" == "\"\\\\x00\"" ]; then
|
||||
search=$(echo -e "$s1")
|
||||
found=$(grep -m1 -n -F "$search" $files | head -n1 | cut -f1-2 -d':' | sed "s/^.*\///")
|
||||
echo "#: $found"
|
||||
echo "#, fuzzy"
|
||||
echo -e "msgid $s1"
|
||||
echo 'msgstr ""'
|
||||
echo
|
||||
else
|
||||
search=$(echo -e "$s1")
|
||||
found=$(grep -m1 -n -F "$search" $files | head -n1 | cut -f1-2 -d':' | sed "s/^.*\///")
|
||||
echo "#: $found"
|
||||
echo -e "msgid $s1"
|
||||
echo -e "msgstr $s0"
|
||||
echo
|
||||
fi
|
||||
num=$((num+1))
|
||||
fi
|
||||
s2=$s1
|
||||
s1=$s0
|
||||
s0=$s
|
||||
s0=$s
|
||||
done >> lang_$LANG.po
|
||||
|
||||
#replace LF with CRLF
|
||||
sync
|
||||
sed -i 's/$/\r/' lang_$LANG.po
|
||||
|
||||
echo "make_po.sh finished" >&2
|
||||
#read
|
||||
exit 0
|
||||
|
|
|
@ -28,7 +28,7 @@ function finish
|
|||
}
|
||||
|
||||
echo "update_lang.sh started" >&2
|
||||
echo "selected language=$LANG" >&2
|
||||
echo " selected language=$LANG" >&2
|
||||
|
||||
echo -n " checking files..." >&2
|
||||
if [ ! -e text.sym ]; then echo "NG! file text.sym not found!" >&2; finish 1; fi
|
||||
|
|
Loading…
Reference in a new issue