2005-11-19 18:23:35 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-09-27 10:25:27 +02:00
|
|
|
# Frontend for ejabberd's extract-tr.sh
|
2005-11-19 18:23:35 +01:00
|
|
|
|
2009-04-27 22:55:35 +02:00
|
|
|
# How to create template files for a new language:
|
|
|
|
# NEWLANG=zh
|
2017-09-27 10:25:27 +02:00
|
|
|
# cp priv/msgs/ejabberd.pot priv/msgs/$NEWLANG.po
|
|
|
|
# echo \{\"\",\"\"\}. > priv/msgs/$NEWLANG.msg
|
|
|
|
# make translations
|
2008-08-17 18:35:58 +02:00
|
|
|
|
|
|
|
extract_lang_src2pot ()
|
|
|
|
{
|
2019-06-22 16:24:15 +02:00
|
|
|
./tools/extract-tr.sh src > priv/msgs/ejabberd.pot
|
2008-08-17 18:35:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_lang_popot2po ()
|
|
|
|
{
|
|
|
|
LANG_CODE=$1
|
|
|
|
PO_PATH=$MSGS_DIR/$LANG_CODE.po
|
2009-04-27 22:55:35 +02:00
|
|
|
POT_PATH=$MSGS_DIR/$PROJECT.pot
|
2008-08-17 18:35:58 +02:00
|
|
|
|
|
|
|
msgmerge $PO_PATH $POT_PATH >$PO_PATH.translate 2>/dev/null
|
2019-06-22 16:24:15 +02:00
|
|
|
mv $PO_PATH.translate $PO_PATH
|
2008-08-17 18:35:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_lang_po2msg ()
|
|
|
|
{
|
|
|
|
LANG_CODE=$1
|
|
|
|
PO_PATH=$LANG_CODE.po
|
|
|
|
MS_PATH=$PO_PATH.ms
|
|
|
|
MSGID_PATH=$PO_PATH.msgid
|
|
|
|
MSGSTR_PATH=$PO_PATH.msgstr
|
|
|
|
MSGS_PATH=$LANG_CODE.msg
|
|
|
|
|
|
|
|
cd $MSGS_DIR
|
|
|
|
|
|
|
|
# Check PO has correct ~
|
|
|
|
# Let's convert to C format so we can use msgfmt
|
|
|
|
PO_TEMP=$LANG_CODE.po.temp
|
|
|
|
cat $PO_PATH | sed 's/%/perc/g' | sed 's/~/%/g' | sed 's/#:.*/#, c-format/g' >$PO_TEMP
|
|
|
|
msgfmt $PO_TEMP --check-format
|
|
|
|
result=$?
|
|
|
|
rm $PO_TEMP
|
|
|
|
if [ $result -ne 0 ] ; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
msgattrib $PO_PATH --translated --no-fuzzy --no-obsolete --no-location --no-wrap | grep "^msg" | tail --lines=+3 >$MS_PATH
|
|
|
|
grep "^msgid" $PO_PATH.ms | sed 's/^msgid //g' >$MSGID_PATH
|
|
|
|
grep "^msgstr" $PO_PATH.ms | sed 's/^msgstr //g' >$MSGSTR_PATH
|
2014-03-12 17:26:27 +01:00
|
|
|
echo "%% -*- coding: latin-1 -*-" >$MSGS_PATH
|
|
|
|
paste $MSGID_PATH $MSGSTR_PATH --delimiter=, | awk '{print "{" $0 "}."}' | sort -g >>$MSGS_PATH
|
2008-08-17 18:35:58 +02:00
|
|
|
|
|
|
|
rm $MS_PATH
|
|
|
|
rm $MSGID_PATH
|
|
|
|
rm $MSGSTR_PATH
|
|
|
|
}
|
|
|
|
|
|
|
|
extract_lang_updateall ()
|
|
|
|
{
|
2017-09-27 10:25:27 +02:00
|
|
|
echo ""
|
|
|
|
echo "Generating POT..."
|
|
|
|
extract_lang_src2pot
|
2008-08-17 18:35:58 +02:00
|
|
|
|
|
|
|
cd $MSGS_DIR
|
|
|
|
echo ""
|
2017-09-27 10:25:27 +02:00
|
|
|
echo -e "File Missing (fuzzy) Language Last translator"
|
|
|
|
echo -e "---- ------- ------- -------- ---------------"
|
2009-04-27 22:55:35 +02:00
|
|
|
for i in $( ls *.msg ) ; do
|
2008-08-17 18:35:58 +02:00
|
|
|
LANG_CODE=${i%.msg}
|
|
|
|
echo -n $LANG_CODE | awk '{printf "%-6s", $1 }'
|
|
|
|
|
|
|
|
PO=$LANG_CODE.po
|
|
|
|
|
|
|
|
extract_lang_popot2po $LANG_CODE
|
|
|
|
extract_lang_po2msg $LANG_CODE
|
|
|
|
|
2017-09-27 10:25:27 +02:00
|
|
|
MISSING=`msgfmt --statistics $PO 2>&1 | awk '{printf "%5s", $4+$7 }'`
|
2008-08-17 18:35:58 +02:00
|
|
|
echo -n " $MISSING"
|
|
|
|
|
2017-09-27 10:25:27 +02:00
|
|
|
FUZZY=`msgfmt --statistics $PO 2>&1 | awk '{printf "%7s", $4 }'`
|
|
|
|
echo -n " $FUZZY"
|
|
|
|
|
2011-10-20 15:45:17 +02:00
|
|
|
LANGUAGE=`grep "X-Language:" $PO | sed 's/\"X-Language: //g' | sed 's/\\\\n\"//g' | awk '{printf "%-12s", $1}'`
|
2008-08-17 18:35:58 +02:00
|
|
|
echo -n " $LANGUAGE"
|
|
|
|
|
|
|
|
LASTAUTH=`grep "Last-Translator" $PO | sed 's/\"Last-Translator: //g' | sed 's/\\\\n\"//g'`
|
|
|
|
echo " $LASTAUTH"
|
|
|
|
done
|
|
|
|
echo ""
|
|
|
|
rm messages.mo
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
2013-04-08 11:12:54 +02:00
|
|
|
EJA_DIR=`pwd`
|
2009-04-27 22:55:35 +02:00
|
|
|
PROJECT=ejabberd
|
2017-09-27 10:25:27 +02:00
|
|
|
MSGS_DIR=$EJA_DIR/priv/msgs
|
2009-04-27 22:55:35 +02:00
|
|
|
|
2017-09-27 10:25:27 +02:00
|
|
|
extract_lang_updateall
|