summaryrefslogtreecommitdiff
path: root/scripts/update_po
blob: 0a8fdd7c40bfab2fae7c9c1ccde9c9ac038c07bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh

# This script is used for translations using .po files.
# It updates .po files after changes in the original English
# .xml files.
# The scripts 'merge_xml' and 'update-pot' should be run before
# this script!

if [ "$1" = "--help" ] ; then
    echo "Usage: $0 <language>"
    exit 0
fi
if [ -z "`which msgmerge 2>/dev/null`" ] ; then
    echo "ERR: Msgmerge not found, please install the gettext package"
    exit 1
fi

language=${1:-pl}

SPODIR="./po"
BUILDDIR="./build"
if [ -z "$PO_USEBUILD" ] ; then
    PODIR=$SPODIR
else
    PODIR="$BUILDDIR/build.po"
    mkdir -p $PODIR/$language
fi
RET=0

[ -d "$PODIR" ] || exit 1

echo "Updating PO files for language '$language':"
for POT in `find $PODIR/pot -name "*.pot"` ; do
    BASENAME="$(basename $POT .pot)"
    PO=$PODIR/$language/$BASENAME.po
    SPO=$SPODIR/$language/$BASENAME.po

    if [ -f $SPO ] ; then
        echo "- updating $BASENAME.po"
        if [ -z "$PO_USEBUILD" ] ; then
            # Update existing PO file
            msgmerge -q -U --previous --backup=simple $PO $POT
            RC=$?
        else
            # Generate temporary PO file in build directory
            msgmerge -q $SPO $POT -o $PO
            RC=$?
        fi
        if [ $RC -ne 0 ] ; then
            RET=$RC
            echo "Error: error $RC while executing msgmerge"
        fi
    else
        echo "Warning: no PO file found for '$BASENAME'."
    fi
done

exit $RET