#!/bin/sh

# This script regenerates main POT file
#
# Philipe Mingo <mingo@rotedic.com>
#
# $Id$

# force use of same locale in order to keep same sorting order
LC_ALL=en_US.ISO8859-1
LANG=en_US.ISO8859-1
export LC_ALL LANG

# set common gettext options
XGETTEXT_OPTIONS="--keyword=_ -keyword=N_ --keyword=ngettext:1,2 --default-domain=squirrelmail --no-location --add-comments=i18n"

# Allows controlling language option
# (gettext v.0.10.40 = -C, gettext 0.11+ = -L php).
if [ $SM_LANG_C ] ; then
 XGETTEXT_OPTIONS="${XGETTEXT_OPTIONS} -C";
else
 XGETTEXT_OPTIONS="${XGETTEXT_OPTIONS} -L php";
fi

cd ..
xgettext ${XGETTEXT_OPTIONS} \
    src/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    class/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    class/*/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    functions/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    functions/template/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    images/themes/*/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    include/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    include/options/*.php --output=po/squirrelmail.pot

# Plugins

xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/administrator/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/bug_report/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/bug_report/templates/default/*.tpl --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/calendar/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/change_password/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/change_password/backend/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/filters/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/fortune/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/info/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/listcommands/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/listcommands/templates/default/*.tpl --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/mail_fetch/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/message_details/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/newmail/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/preview_pane/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/sent_subfolders/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/spamcop/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/squirrelspell/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/squirrelspell/class/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/squirrelspell/modules/*.mod --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    plugins/translate/*.php --output=po/squirrelmail.pot

# Templates

xgettext ${XGETTEXT_OPTIONS} -j \
    templates/*.php --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    templates/default/*.tpl --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    templates/default/plugins/fortune/*.tpl --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    templates/default/plugins/listcommands/*.tpl --output=po/squirrelmail.pot
xgettext ${XGETTEXT_OPTIONS} -j \
    templates/default_advanced/*.tpl --output=po/squirrelmail.pot

# Independent strings

xgettext ${XGETTEXT_OPTIONS} -j \
    po/independent_strings.txt --output=po/squirrelmail.pot

# print stats
msgfmt --statistics ${SM_LOCALES_PATH}/po/squirrelmail.pot -o /dev/null

cd po
