#!/bin/sh

#  * Copyright © 2002 Wilbert Berendsen <wilbert@oswf.org>
#  *
#  * This file is free software; you can redistribute it and/or modify it
#  * under the terms of the GNU General Public License as published by
#  * the Free Software Foundation; either version 3 of the License, or
#  * (at your option) any later version.
#  *
#  * This program is distributed in the hope that it will be useful, but
#  * WITHOUT ANY WARRANTY; without even the implied warranty of
#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  * General Public License for more details.
#  *
#  * You should have received a copy of the GNU General Public License
#  * along with this program; if not, write to the Free Software
#  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#  *

# update-po -- for Claws Mail
# by Wilbert Berendsen
# This script updates the .po files named on the command line.
# Run this script from within the po/ directory!

if [ "$1" -a -f "$1" ] ; then

	
        #
        # Make a messages.pot file containing all the msgid's from
        # the source

	make -C .. -f - <<EOF

sources = \$(shell cat po/POTFILES.in)
po/messages.pot: \$(sources) po/POTFILES.in
	xgettext --keyword=N_ --keyword=_ --keyword=Q_ --file=po/POTFILES.in \
	        --output=po/messages.pot
EOF

	#
        # Update all the xx.po files named on the commandline.

	for po in $@ ; do
        
        	# Save xx.po in xx.po.old

        	cp $po $po.old
                echo "Updating $po..."
                msgmerge $po.old messages.pot > $po
	done

else

	echo
	echo "Usage:"
        echo
        echo "        ./`basename $0` lang.po lang2.po ..."
        echo
        echo "to update one or more <yourlang>.po files from the sourcecode files"
        echo "named in POTFILES.in. The old .po file is save in a .po.old file."
        echo
        echo "When you e.g. want to update fr.po, run ./`basename $0` fr.po, then"
        echo "edit fr.po to update your translation."
        echo

fi
