<?php

require_once 'Swat/SwatException.php';

/**
 * Container for package wide static methods
 *
 * @package   Swat
 * @copyright 2005 silverorange
 * @license   http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
 */
class Swat
{
	const GETTEXT_DOMAIN = 'swat';

	function _($message)
	{
		return Swat::gettext($message);
	}

	function gettext($message)
	{
		return dgettext(Swat::GETTEXT_DOMAIN, $message);
	}

	function ngettext($singular_message, $plural_message, $number)
	{
		return dngettext(Swat::GETTEXT_DOMAIN, $singular_message, $plural_message, $number);
	}

}

?>

<?php

require_once 'Swat/SwatException.php';

/**
 * Container for package wide static methods
 *
 * @package   Swat
 * @copyright 2005 silverorange
 * @license   http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
 */
class Swat
{
	/**
	 * The gettext domain for Swat
	 *
	 * This is used to support multiple locales.
	 */
	const GETTEXT_DOMAIN = 'swat';

	/**
	 * Translates a phrase
	 *
	 * This is an alias for {@link Swat::gettext()}.
	 *
	 * @param string $message the phrase to be translated.
	 *
	 * @return string the translated phrase.
	 */
	public static function _($message)
	{
		return Swat::gettext($message);
	}

	/**
	 * Translates a phrase
	 *
	 * This method relies on the php gettext extension and uses dgettext()
	 * internally.
	 *
	 * @param string $message the phrase to be translated.
	 *
	 * @return string the translated phrase.
	 */
	public static function gettext($message)
	{
		return dgettext(Swat::GETTEXT_DOMAIN, $message);
	}

	/**
	 * Translates a plural phrase
	 *
	 * This method should be used when a phrase depends on a number. For
	 * example, use ngettext when translating a dynamic phrase like:
	 *
	 * - "There is 1 new item" for 1 item and
	 * - "There are 2 new items" for 2 or more items.
	 *
	 * This method relies on the php gettext extension and uses dngettext()
	 * internally.
	 *
	 * @param string $singular_message the message to use when the number the
	 *                                  phrase depends on is one.
	 * @param string $plural_message the message to use when the number the
	 *                                phrase depends on is more than one.
	 * @param integer $number the number the phrase depends on.
	 *
	 * @return string the translated phrase.
	 */
	public static function ngettext($singular_message, $plural_message, $number)
	{
		return dngettext(Swat::GETTEXT_DOMAIN,
			$singular_message, $plural_message, $number);
	}
}

?>

Clean up and document this class. - Added scope and static modifiers to method definitions. - Added documentation - Wrapped lines at 80 chars.
Clean up and document this class.
- Added scope and static modifiers to method definitions.
- Added documentation
- Wrapped lines at 80 chars.


svn commit r1717
