| 1 |
#!/bin/sh
|
| 2 |
|
| 3 |
# This script is used for translations using .po files.
|
| 4 |
# It creates .xml files from the translated .po files.
|
| 5 |
|
| 6 |
if [ "$1" = "--help" ] ; then
|
| 7 |
echo "Usage: $0 <language>"
|
| 8 |
exit 0
|
| 9 |
fi
|
| 10 |
|
| 11 |
language=${1:-pl}
|
| 12 |
|
| 13 |
BUILDDIR="./build"
|
| 14 |
if [ -z "$PO_USEBUILD" ] ; then
|
| 15 |
WORKDIR="./integrated"
|
| 16 |
PODIR="./po"
|
| 17 |
else
|
| 18 |
WORKDIR="$BUILDDIR/build.po"
|
| 19 |
PODIR="$BUILDDIR/build.po"
|
| 20 |
fi
|
| 21 |
SOURCEDIR="$WORKDIR/en"
|
| 22 |
# Don't overwrite XML translations committed to SVN
|
| 23 |
if [ -d "./$language/.svn" ] ; then
|
| 24 |
TARGETDIR="./$language.new"
|
| 25 |
else
|
| 26 |
TARGETDIR="./$language"
|
| 27 |
fi
|
| 28 |
RET=0
|
| 29 |
|
| 30 |
[ -d "$SOURCE" -o -d "$PODIR" ] || exit 1
|
| 31 |
|
| 32 |
[ -d "$TARGETDIR" ] && rm -r $TARGETDIR
|
| 33 |
|
| 34 |
echo "Creating XML files for language '$language':"
|
| 35 |
for ORIGXML in `find $SOURCEDIR -name "*.xml"` ; do
|
| 36 |
BASEDIR=$(dirname $ORIGXML | sed "s:$SOURCEDIR::" | sed "s:^/::")
|
| 37 |
BASENAME=$(basename $ORIGXML .xml)
|
| 38 |
PO=$PODIR/$language/$BASENAME.po
|
| 39 |
XML=$TARGETDIR/$BASEDIR/$BASENAME.xml
|
| 40 |
|
| 41 |
mkdir -p $TARGETDIR/$BASEDIR
|
| 42 |
|
| 43 |
if [ -f $PO ] ; then
|
| 44 |
echo "- creating $BASENAME.xml"
|
| 45 |
po2xml $ORIGXML $PO > $XML
|
| 46 |
RC=$?
|
| 47 |
if [ $RC -ne 0 ] ; then
|
| 48 |
RET=$RC
|
| 49 |
echo "Error: error $RC while executing po2xml"
|
| 50 |
fi
|
| 51 |
else
|
| 52 |
echo "Warning: no PO file found for '$BASENAME'; copying English original"
|
| 53 |
cp $ORIGXML $TARGETDIR/$BASEDIR
|
| 54 |
fi
|
| 55 |
done
|
| 56 |
|
| 57 |
exit $RET
|