#!/bin/bash
# extracts strings from *.py and .ui files and
# generates a gettext .pot template.

glade_dir=./Mailnag/configuration/ui
python_dir=./Mailnag
pot_file=./po/mailnagger.pot

if [ ! -d ./po ]; then
	mkdir ./po
fi

if [ -f $pot_file ]; then
	rm $pot_file
fi

# generate string headers of all glade files
for f in $glade_dir/*.ui ; do
	intltool-extract --type=gettext/glade $f
done

# write template files
pyfiles=`find $python_dir -iname "*.py" -printf "%p "`
xgettext $pyfiles $glade_dir/*.h --keyword=_ --keyword=N_ --add-comments="TRANSLATORS:" --from-code=UTF-8 --copyright-holder="2024 Timo Kankare <timo.kankare@iki.fi>" --package-name="Mailnagger" --package-version="2.3.0" --msgid-bugs-address="https://github.com/tikank/mailnagger/issues" --output=$pot_file

# clean up
rm $glade_dir/*.h
