#!/bin/sh
messagesFile=messages.pot
messagesCS=messages.cs.po
messagesCSMO=messages.cs.mo
messagesEN=messages.en.po
messagesENMO=messages.en.mo
sourceDir=../../application

> $messagesFile

srcFiles=`find $sourceDir -type f \( -name '*.phtml' -o -name '*.php' \) -print`
srcFiles=`echo ${srcFiles} ./staticMessages.php`

for file in $srcFiles; do
 if [ `expr $file : '.*\/lib'` -gt 0 -o `expr $file : '.*zip'` -gt 0 ]; then  
  continue; 
 fi;  
 echo "scannig $file"
 xgettext -j --keyword=trans --from-code=ascii \
 --default-domain=messages --language=php \
 --output=$messagesFile \
 $file
done

echo "updating CS PO"
msgmerge -U $messagesCS $messagesFile
echo "updating EN PO"
msgmerge -U $messagesEN $messagesFile

echo "formating CS MO"
msgfmt $messagesCS -o $messagesCSMO
echo "formating EN MO"
msgfmt $messagesEN -o $messagesENMO

rm -f ./*~
