Warning, file /sdk/pology/po/pology/update-po.sh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #!/bin/bash
0002 
0003 wdir=`pwd`
0004 cdir=`dirname $0`
0005 podomain=pology
0006 
0007 mode=all
0008 if test -n "$1"; then
0009     mode=$1
0010 fi
0011 onelang=
0012 if test -n "$2"; then
0013     onelang=$2
0014 fi
0015 
0016 if [[ :all:extract:test:compile: != *:$mode:* ]]; then
0017     echo "*** Unknown mode '$mode'."
0018     echo "*** (Known modes: all, extract, merge, compile.)"
0019     exit 1
0020 fi
0021 
0022 if test $mode = all || test $mode = extract; then
0023     echo ">>> Extracting template..."
0024     cd $cdir/../..
0025     # Do not just look for all *.py, keep some ordering.
0026     srcfiles_lib=`find pology -maxdepth 1 -iname \*.py | sort`
0027     srcfiles_libpr=`find pology/proj/* -maxdepth 1 -iname \*.py | sort`
0028     srcfiles_liblg=`find pology/lang/* -maxdepth 1 -iname \*.py | sort`
0029     srcfiles_libin=`find pology/internal/* -maxdepth 1 -iname \*.py | sort`
0030     srcfiles_script=`find scripts -maxdepth 1 -iname \*.py | sort`
0031     srcfiles_scriptlg=`find lang -iname \*.py | grep /scripts/ | sort`
0032     srcfiles_sieve=`find sieve -maxdepth 1 -iname \*.py | sort`
0033     srcfiles_sievelg=`find lang -iname \*.py | grep /sieve/ | sort`
0034     srcfiles="\
0035         $srcfiles_lib $srcfiles_libpr $srcfiles_liblg $srcfiles_libin \
0036         $srcfiles_script $srcfiles_scriptlg \
0037         $srcfiles_sieve $srcfiles_sievelg \
0038     "
0039     potfile=po/$podomain/$podomain.pot
0040     xgettext --no-wrap \
0041         -k_:1c,2 -kn_:1c,2,3 -kt_:1c,2 -ktn_:1c,2,3 \
0042         -o $potfile $srcfiles
0043     cd $wdir
0044 fi
0045 
0046 if test $mode = all || test $mode = merge; then
0047     echo ">>> Merging catalogs..."
0048     potfile=$cdir/$podomain.pot
0049     if [ -z "$onelang" ]; then
0050         langs=`cat $cdir/LINGUAS | sed 's/#.*//'`
0051     else
0052         langs=$onelang
0053     fi
0054     for lang in $langs; do
0055         pofile=$cdir/$lang.po
0056         if test ! -f $pofile; then
0057             echo "--- $pofile is missing."
0058             continue
0059         fi
0060         echo -n "$pofile  "
0061         msgmerge -U --backup=none --no-wrap --previous $pofile $potfile
0062     done
0063 fi
0064 
0065 if test $mode = all || test $mode = compile; then
0066     echo ">>> Compiling catalogs..."
0067     modir=$cdir/../../mo
0068     # Remove old compiled dir if in pristine state, otherwise warn and exit.
0069     if [ -d $modir ]; then
0070         nonmofiles=`find $modir -type f | egrep -v '.*\.mo$'`
0071         if [ -n "$nonmofiles" ]; then
0072             echo "$nonmofiles"
0073             echo "*** $modir contains non-compiled files."
0074             echo "*** Move them or delete them, then rerun the script."
0075             exit 1
0076         fi
0077         rm -rf $modir
0078     elif [ -e $modir ]; then
0079         echo "*** $modir not a directory."
0080         echo "*** Move it or delete it, then rerun the script."
0081         exit 1
0082     fi
0083 
0084     if [ -z "$onelang" ]; then
0085         langs=`cat $cdir/LINGUAS | sed 's/#.*//'`
0086     else
0087         langs=$onelang
0088     fi
0089     for lang in $langs; do
0090         pofile=$cdir/$lang.po
0091         if test ! -f $pofile; then
0092             echo "--- $pofile is missing."
0093             continue
0094         fi
0095         echo -n "$pofile  "
0096         pobase=`basename $pofile`
0097         mosubdir=$modir/$lang/LC_MESSAGES
0098         mkdir -p $mosubdir
0099         mofile=$mosubdir/$podomain.mo
0100         msgfmt -c --statistics $pofile -o $mofile
0101     done
0102 fi
0103