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 ()
|
|
|
|
{
|
2021-01-22 12:58:44 +01:00
|
|
|
./tools/extract-tr.sh src deps/xmpp/src > $PO_DIR/ejabberd.pot
|
2008-08-17 18:35:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_lang_popot2po ()
|
|
|
|
{
|
|
|
|
LANG_CODE=$1
|
2021-01-22 12:58:44 +01:00
|
|
|
PO_PATH=$PO_DIR/$LANG_CODE.po
|
|
|
|
POT_PATH=$PO_DIR/$PROJECT.pot
|
2008-08-17 18:35:58 +02:00
|
|
|
|
2020-04-17 17:25:40 +02:00
|
|
|
msgmerge $PO_PATH $POT_PATH >$PO_PATH.translate 2>>$LOG
|
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
|
|
|
|
|
2021-01-22 12:58:44 +01:00
|
|
|
cd $PO_DIR
|
2008-08-17 18:35:58 +02:00
|
|
|
|
|
|
|
# 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
|
2021-02-02 00:28:32 +01:00
|
|
|
echo "%% Generated automatically" >$MSGS_PATH
|
|
|
|
echo "%% DO NOT EDIT: run \`make translations\` instead" >>$MSGS_PATH
|
|
|
|
echo "%% To improve translations please read:" >>$MSGS_PATH
|
|
|
|
echo "%% https://docs.ejabberd.im/developer/extending-ejabberd/localization/" >>$MSGS_PATH
|
|
|
|
echo "" >>$MSGS_PATH
|
2014-03-12 17:26:27 +01:00
|
|
|
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
|
2021-01-22 12:58:44 +01:00
|
|
|
|
|
|
|
mv $MSGS_PATH $MSGS_DIR
|
2008-08-17 18:35:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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 }'
|
|
|
|
|
2021-01-22 12:58:44 +01:00
|
|
|
PO=$PO_DIR/$LANG_CODE.po
|
2008-08-17 18:35:58 +02:00
|
|
|
|
|
|
|
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
|
2020-04-17 19:17:56 +02:00
|
|
|
grep -v " done" $LOG
|
2020-04-17 17:25:40 +02:00
|
|
|
rm $LOG
|
2008-08-17 18:35:58 +02:00
|
|
|
|
|
|
|
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
|
2020-04-17 17:25:40 +02:00
|
|
|
LOG=/tmp/ejabberd-translate-errors.log
|
2021-01-22 12:58:44 +01:00
|
|
|
if [ -f $EJA_DIR/deps/ejabberd_po/src/ejabberd.pot ]; then
|
|
|
|
PO_DIR=$EJA_DIR/deps/ejabberd_po/src/
|
|
|
|
else
|
|
|
|
if [ -f $EJA_DIR/_build/default/lib/ejabberd_po/src/ejabberd.pot ]; then
|
|
|
|
PO_DIR=$EJA_DIR/_build/default/lib/ejabberd_po/src
|
|
|
|
else
|
|
|
|
echo "Couldn't find the required ejabberd_po repository."
|
|
|
|
echo "Run: ./configure --enable-tools; ./rebar get-deps"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "Using PO files found in $PO_DIR."
|
2009-04-27 22:55:35 +02:00
|
|
|
|
2017-09-27 10:25:27 +02:00
|
|
|
extract_lang_updateall
|