summaryrefslogtreecommitdiff
path: root/scripts/update_po
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/update_po')
-rwxr-xr-xscripts/update_po58
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/update_po b/scripts/update_po
new file mode 100755
index 000000000..9432c7659
--- /dev/null
+++ b/scripts/update_po
@@ -0,0 +1,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 --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