#!/bin/sh

# ispCP ω (OMEGA) a Virtual Hosting Control Panel
# Copyright (C) 2006-2010 by isp Control Panel - http://ispcp.net
#
# Version: $Id: makemsgs 3654 2010-11-21 19:52:01Z benedikt $
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is "ispCP ω (OMEGA) a Virtual Hosting Control Panel".
#
# The Initial Developer of the Original Code is ispCP Team.
# Portions created by Initial Developer are Copyright (C) 2006-2010 by
# isp Control Panel. All Rights Reserved.
#
# The ispCP ω Home Page is:
#
#    http://isp-control.net
#

# description:
#
# creates the main ispcp.pot file out of any found strings in the php files
#
# Warning: This script will remove any strings which aren't present in the GUI
# php files, this means dynamic strings or strings out of the database will
# ignored.
#

set -e

if [ $1 ] && [ -d $1 ]; then
	GUI=${1}/
else
	GUI=../../gui/
fi

if [ ! -f ${GUI}/index.php ]; then
	if [ -f ${GUI}/gui/index.php ]; then
		GUI=${GUI}/gui/
	fi
fi

if [ ! -f ${GUI}/index.php ]; then
	echo "${GUI} isn't a valid gui/ location!"
	exit 1
fi

/usr/bin/xgettext --language=PHP --output-dir=${GUI}../language-files/po \
	--copyright-holder=ispCP\ Team --keyword=tr --no-wrap --default-domain=ispCP \
	--output=ispCP.pot --no-location --from-code=utf-8 \
	${GUI}/include/i18n.php ${GUI}*.php ${GUI}*/*.php

sed --in-place '/#. Please ignore this entry/d' ${GUI}../language-files/po/ispCP.pot
sed --in-place 's/msgid "encoding"/#. Please ignore this entry\nmsgid "encoding"/' ${GUI}../language-files/po/ispCP.pot
sed --in-place '/#. Please fill in the language you are translating to in the following form:\n#. native language name (native country name) - english language name (english country name)/d' ${GUI}../language-files/po/ispCP.pot
sed --in-place 's/msgid "_: Localised language"/#. Please fill in the language you are translating to in the following form:\n#. native language name (native country name) - english language name (english country name)\nmsgid "_: Localised language"/' ${GUI}../language-files/po/ispCP.pot

exit 0
