#!/bin/bash
if [ "$1" != "update" ] && [ "$1" != "compile" ]; then
echo -e "Usage: $0 update|compile\n\tupdate: update po files\n\tcompile: compile po files to mo files\n"
exit 1;
elif [ "$(whereis intltool)" == "intltool:" ] || [ "$(whereis xgettext)" == "xgettext:" ] || [ "$(whereis msginit)" == "msginit:" ] || [ "$(whereis msgfmt)" == "msgfmt:" ]; then
echo "Error: you need to have intltool and gettext installed.";
exit 1;
fi;
# Add languages here!
LANGS="de fr it";
if [ "$1" == "update" ]; then
cd src;
intltool-extract --type=gettext/glade gimagereader.xml;
xgettext -k_ -kN_ -o ../po/gimagereader.pot *.py *.h;
cd ../po;
for l in $LANGS; do
if [ ! -e $l.po ]; then
echo -n "* Creating translation for $l...";
msginit --input=gimagereader.pot --locale=$l;
else
echo -n "* Updating translation for $l...";
msgmerge -U $l.po gimagereader.pot;
fi;
done;
rm -f ../src/gimagereader.xml.h;
rm -f *~;
elif [ "$1" == "compile" ]; then
cd po;
mkdir -p utf8 iso8859;
for l in $LANGS; do
mkdir -p ../src/locale/$l/LC_MESSAGES/ utf8/$l iso8859/$l;
echo "* Compiling translation for $l...";
# UTF-8
msgfmt $l.po -o utf8/$l/gimagereader.mo;
cp utf8/$l/gimagereader.mo ../src/locale/$l/LC_MESSAGES/gimagereader.mo;
# ISO-8859-1
sed 's/charset=UTF-8/charset=ISO-8859-1/' < $l.po > $l.iso8859.po
msgfmt $l.iso8859.po -o iso8859/$l/gimagereader.mo;
rm $l.iso8859.po
done;
fi;
echo "* Done!";
exit 0;