#!/bin/sh

OUTPUT_CHARSET=$2

if [ "$OUTPUT_CHARSET" = "" ]
then
{
	OUTPUT_CHARSET="ISO-8859-1"
}
fi

echo "Merging $1.po and wordtrans.pot"
msgmerge --output-file=$1.pox $1.po wordtrans.pot

echo "Creating binary catalog $1.mo from $1.pox (for wordtrans and qwordtrans)"
msgfmt --statistics --output-file=$1.mo $1.pox

echo "Converting $1.pox (charset:$OUTPUT_CHARSET) to $1-utf8.pox"
iconv -f $OUTPUT_CHARSET -t UTF-8 -o $1.tmp $1.pox
sed -e "s/\"Content-Type:.*/\"Content-Type: text\/plain; charset=UTF-8\\\n\"/" $1.tmp >> $1-utf8.pox
rm $1.tmp

echo "Creating binary catalog $1-utf8.mo from $1-utf8.pox (for kwordtrans)"
msgfmt --statistics --output-file=$1-utf8.mo $1-utf8.pox

