#!/bin/bash

#
# Update the .pot file for clearFusionCMS module
#

OPTS="-j -L PHP --from-code=UTF-8 --keyword=__:1 --keyword=_n:1,2 --keyword=__noop:1 --keyword=_n_noop:1,2"

# Build a temporary .po file
echo "Building manager message list ..."
cp header.pot messages.po

# Build backend
SRC=`find ../../ -name "*Settings.php" -print`
for f in $SRC
do
	xgettext $OPTS $f
done

SRC=`find ../../ -name "*Install.php" -print`
for f in $SRC
do
	xgettext $OPTS $f
done

# Merge the temp .po file into the .pot file
echo "Merging messages into .pot file ..."
msgmerge --update liveeditorBackend.pot messages.po

# Delete the temp file
echo "Cleaning up ..."
rm messages.po

# Update language specific .pot file
echo "Updating .po files ..."
TRANS=`find ../../lang/ -iname "??_??" -print`
for f in $TRANS
do
	echo "Updating $f"
	msgmerge --update $f/liveeditorBackend.po liveeditorBackend.pot
done
