#!/bin/bash

if ! command -v xgettext &> /dev/null
then
	echo "xgettext could not be found."
	echo "you can install the package with 'apt install gettext' command on debian."
	exit
fi


echo "updating pot file"
xgettext -o po/eta-usb-login.pot --from-code="utf-8" \
    `find src -type f -iname "*.py"`

for lang in $(cat po/LINGUAS); do
	if [[ -f po/$lang.po ]]; then
		echo "updating $lang.po"
		msgmerge -o po/$lang.po po/$lang.po po/eta-usb-login.pot
	else
		echo "creating $lang.po"
		cp po/eta-usb-login.pot po/$lang.po
	fi
done
