Hello community, here is the log from the commit of package php5-pear-Horde_Translation for openSUSE:Factory checked in at Tue Aug 16 10:20:21 CEST 2011. -------- --- php5-pear-Horde_Translation/php5-pear-Horde_Translation.changes 2011-04-06 18:40:21.000000000 +0200 +++ /mounts/work_src_done/STABLE/php5-pear-Horde_Translation/php5-pear-Horde_Translation.changes 2011-08-15 00:51:35.000000000 +0200 @@ -1,0 +2,6 @@ +Sun Aug 14 22:50:59 UTC 2011 - lang@b1-systems.de + +- version 1.0.1 +- [cjh] Don't extend Horde_Translation_Exception from Horde_Exception_Wrapped to avoid circular dependency. + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- Horde_Translation-1.0.0.tgz New: ---- Horde_Translation-1.0.1.tgz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ php5-pear-Horde_Translation.spec ++++++ --- /var/tmp/diff_new_pack.f1MerE/_old 2011-08-16 10:19:59.000000000 +0200 +++ /var/tmp/diff_new_pack.f1MerE/_new 2011-08-16 10:19:59.000000000 +0200 @@ -22,16 +22,15 @@ Summary: PEAR: Horde translation library Name: php5-pear-Horde_Translation -Version: 1.0.0 +Version: 1.0.1 Release: 1 -License: LGPL +License: LGPL-2.1 Group: Development/Libraries/PHP Source0: http://pear.horde.org/get/Horde_Translation-%{version}.tgz BuildRoot: %{_tmppath}/%{name}-%{version}-build Url: http://pear.horde.org/package/Horde_Translation -BuildRequires: php5-pear >= 1.4.7 +BuildRequires: php5-pear >= 1.7.0 Requires: php5-pear-Horde_Exception < 2.0.0, php5-pear >= 1.7.0 -Conflicts: php5-pear-Horde_Exception = 2.0.0 BuildRequires: php5-pear-channel-horde Requires: php5-pear-channel-horde BuildArch: noarch @@ -76,23 +75,23 @@ # Install XML package description mkdir -p %{buildroot}%{xmldir} tar -xzf %{SOURCE0} package.xml -cp -p package.xml %{buildroot}%{xmldir}/Horde_Translation.xml +cp -p package.xml %{buildroot}%{xmldir}/%{pear_name}.xml %clean rm -rf %{buildroot} %post -pear install --nodeps --soft --force --register-only %{xmldir}/Horde_Translation.xml +pear install --nodeps --soft --force --register-only %{xmldir}/%{pear_name}.xml %postun if [ "$1" -eq "0" ]; then - pear uninstall --nodeps --ignore-errors --register-only pear.horde.org/Horde_Translation + pear uninstall --nodeps --ignore-errors --register-only pear.horde.org/%{pear_name} fi %files -f %{pear_name}.lang %defattr(-,root,root) %{peardir}/* -%{xmldir}/Horde_Translation.xml +%{xmldir}/%{pear_name}.xml %changelog ++++++ Horde_Translation-1.0.0.tgz -> Horde_Translation-1.0.1.tgz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.0/lib/Horde/Translation/Exception.php new/Horde_Translation-1.0.0/lib/Horde/Translation/Exception.php --- old/Horde_Translation-1.0.0/lib/Horde/Translation/Exception.php 2011-04-06 01:22:32.000000000 +0200 +++ new/Horde_Translation-1.0.0/lib/Horde/Translation/Exception.php 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ -<?php -/** - * Exception class for Horde_Translation. - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @author Jan Schneider <jan@horde.org> - * @package Translation - */ -class Horde_Translation_Exception extends Horde_Exception_Wrapped -{ -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.0/lib/Horde/Translation/Handler/Gettext.php new/Horde_Translation-1.0.0/lib/Horde/Translation/Handler/Gettext.php --- old/Horde_Translation-1.0.0/lib/Horde/Translation/Handler/Gettext.php 2011-04-06 01:22:32.000000000 +0200 +++ new/Horde_Translation-1.0.0/lib/Horde/Translation/Handler/Gettext.php 1970-01-01 01:00:00.000000000 +0100 @@ -1,82 +0,0 @@ -<?php -/** - * @package Translation - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - */ - -/** - * The Horde_Translation_Handler_Gettext provides translations through the - * gettext extension, but fails gracefully if gettext is not installed. - * - * @author Jan Schneider <jan@horde.org> - * @package Translation - */ -class Horde_Translation_Handler_Gettext implements Horde_Translation_Handler -{ - /** - * The translation domain, e.g. package name. - * - * @var string - */ - protected $_domain; - - /** - * Whether the gettext extension is installed. - * - * @var boolean - */ - protected $_gettext; - - /** - * Constructor. - * - * @param string $domain The translation domain, e.g. package name. - * @param string $path The path to the gettext catalog. - */ - public function __construct($domain, $path) - { - if (!is_dir($path)) { - throw new InvalidArgumentException("$path is not a directory"); - } - $this->_gettext = function_exists('_'); - if (!$this->_gettext) { - return; - } - $this->_domain = $domain; - bindtextdomain($this->_domain, $path); - } - - /** - * Returns the translation of a message. - * - * @param string $message The string to translate. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - public function t($message) - { - return $this->_gettext ? dgettext($this->_domain, $message) : $message; - } - - /** - * Returns the plural translation of a message. - * - * @param string $singular The singular version to translate. - * @param string $plural The plural version to translate. - * @param integer $number The number that determines singular vs. plural. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - public function ngettext($singular, $plural, $number) - { - return $this->_gettext - ? dngettext($this->_domain, $singular, $plural, $number) - : ($number > 1 ? $plural : $singular); - } -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.0/lib/Horde/Translation/Handler.php new/Horde_Translation-1.0.0/lib/Horde/Translation/Handler.php --- old/Horde_Translation-1.0.0/lib/Horde/Translation/Handler.php 2011-04-06 01:22:32.000000000 +0200 +++ new/Horde_Translation-1.0.0/lib/Horde/Translation/Handler.php 1970-01-01 01:00:00.000000000 +0100 @@ -1,41 +0,0 @@ -<?php -/** - * @package Translation - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - */ - -/** - * The Horde_Translation_Handler interface defines the interface for any - * classes providing translations. - * - * @author Jan Schneider <jan@horde.org> - * @package Translation - */ -interface Horde_Translation_Handler -{ - /** - * Returns the translation of a message. - * - * @var string $message The string to translate. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - public function t($message); - - /** - * Returns the plural translation of a message. - * - * @param string $singular The singular version to translate. - * @param string $plural The plural version to translate. - * @param integer $number The number that determines singular vs. plural. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - public function ngettext($singular, $plural, $number); -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.0/lib/Horde/Translation.php new/Horde_Translation-1.0.0/lib/Horde/Translation.php --- old/Horde_Translation-1.0.0/lib/Horde/Translation.php 2011-04-06 01:22:32.000000000 +0200 +++ new/Horde_Translation-1.0.0/lib/Horde/Translation.php 1970-01-01 01:00:00.000000000 +0100 @@ -1,111 +0,0 @@ -<?php -/** - * @package Translation - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - */ - -/** - * Horde_Translation is the base class for any translation wrapper classes in - * libraries that want to utilize the Horde_Translation library for - * translations. - * - * @author Jan Schneider <jan@horde.org> - * @package Translation - */ -abstract class Horde_Translation -{ - /** - * The translation domain, e.g. the library name, for the default gettext - * handler. - * - * @var string - */ - static protected $_domain; - - /** - * The relative path to the translations for the default gettext handler. - * - * This path is relative to the - * - * @var string - */ - static protected $_directory; - - /** - * The handlers providing the actual translations. - * - * @var array - */ - static protected $_handlers = array(); - - /** - * Loads a translation handler class pointing to the library's translations - * and assigns it to $_handler. - * - * @param string $handlerClass The name of a class implementing the - * Horde_Translation_Handler interface. - */ - static public function loadHandler($handlerClass) - { - if (!self::$_domain || !self::$_directory) { - throw new Horde_Translation_Exception('The domain and directory properties must be set by the class that extends Horde_Translation.'); - } - self::setHandler(self::$_domain, new $handlerClass(self::$_domain, self::$_directory)); - } - - /** - * Assigns a translation handler object to $_handlers. - * - * Type hinting isn't used on purpose. You should extend a custom - * translation handler passed here from the Horde_Translation interface, - * but technically it's sufficient if you provide the API of that - * interface. - * - * @param string $domain The translation domain. - * @param Horde_Translation_Handler $handler An object implementing the - * Horde_Translation_Handler - * interface. - */ - static public function setHandler($domain, $handler) - { - self::$_handlers[$domain] = $handler; - } - - /** - * Returns the translation of a message. - * - * @var string $message The string to translate. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - static public function t($message) - { - if (!isset(self::$_handlers[self::$_domain])) { - self::loadHandler('Horde_Translation_Handler_Gettext'); - } - return self::$_handlers[self::$_domain]->t($message); - } - - /** - * Returns the plural translation of a message. - * - * @param string $singular The singular version to translate. - * @param string $plural The plural version to translate. - * @param integer $number The number that determines singular vs. plural. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - static public function ngettext($singular, $plural, $number) - { - if (!isset(self::$_handlers[self::$_domain])) { - self::loadHandler('Horde_Translation_Handler_Gettext'); - } - return self::$_handlers[self::$_domain]->ngettext($singular, $plural, $number); - } -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.0/test/Horde/Translation/AllTests.php new/Horde_Translation-1.0.0/test/Horde/Translation/AllTests.php --- old/Horde_Translation-1.0.0/test/Horde/Translation/AllTests.php 2011-04-06 01:22:32.000000000 +0200 +++ new/Horde_Translation-1.0.0/test/Horde/Translation/AllTests.php 1970-01-01 01:00:00.000000000 +0100 @@ -1,36 +0,0 @@ -<?php -/** - * Horde_Translation test suite. - * - * @author Jan Schneider <jan@horde.org> - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @category Horde - * @package Translation - * @subpackage UnitTests - */ - -/** - * Define the main method - */ -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Horde_Translation_AllTests::main'); -} - -/** - * Prepare the test setup. - */ -require_once 'Horde/Test/AllTests.php'; - -/** - * @package Translation - * @subpackage UnitTests - */ -class Horde_Translation_AllTests extends Horde_Test_AllTests -{ -} - -Horde_Translation_AllTests::init('Horde_Translation', __FILE__); - -if (PHPUnit_MAIN_METHOD == 'Horde_Translation_AllTests::main') { - Horde_Translation_AllTests::main(); -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.0/test/Horde/Translation/GettextTest.php new/Horde_Translation-1.0.0/test/Horde/Translation/GettextTest.php --- old/Horde_Translation-1.0.0/test/Horde/Translation/GettextTest.php 2011-04-06 01:22:32.000000000 +0200 +++ new/Horde_Translation-1.0.0/test/Horde/Translation/GettextTest.php 1970-01-01 01:00:00.000000000 +0100 @@ -1,49 +0,0 @@ -<?php - -require_once dirname(__FILE__) . '/TestBase.php'; - -/** - * @author Jan Schneider <jan@horde.org> - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @category Horde - * @package Translation - * @subpackage UnitTests - */ -class Horde_Translation_GettextTest extends Horde_Translation_TestBase -{ - private $_dict; - private $_otherDict; - - public function setUp() - { - parent::setUp(); - $this->_dict = new Horde_Translation_Handler_Gettext('Horde_Translation', dirname(__FILE__) . '/locale'); - $this->_otherDict = new Horde_Translation_Handler_Gettext('Horde_Other', dirname(__FILE__) . '/locale'); - } - - public function testGettext() - { - $this->assertEquals('Heute', $this->_dict->t('Today')); - $this->assertEquals('Schön', $this->_dict->t('Beautiful')); - $this->assertEquals('2 Tage', sprintf($this->_dict->t('%d days'), 2)); - $this->assertEquals('Morgen', $this->_otherDict->t('Tomorrow')); - } - - public function testNgettext() - { - $this->assertEquals('1 Woche', sprintf($this->_dict->ngettext('%d week', '%d weeks', 1), 1)); - $this->assertEquals('2 Wochen', sprintf($this->_dict->ngettext('%d week', '%d weeks', 2), 2)); - } - - public function testInvalidConstruction() - { - try { - new Horde_Translation_Handler_Gettext('Horde_Translation', dirname(__FILE__) . '/DOES_NOT_EXIST'); - } catch (InvalidArgumentException $e) { - $this->assertEquals( - dirname(__FILE__) . '/DOES_NOT_EXIST is not a directory', - $e->getMessage() - ); - } - } -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.0/test/Horde/Translation/TestBase.php new/Horde_Translation-1.0.0/test/Horde/Translation/TestBase.php --- old/Horde_Translation-1.0.0/test/Horde/Translation/TestBase.php 2011-04-06 01:22:32.000000000 +0200 +++ new/Horde_Translation-1.0.0/test/Horde/Translation/TestBase.php 1970-01-01 01:00:00.000000000 +0100 @@ -1,42 +0,0 @@ -<?php -/** - * @author Jan Schneider <jan@horde.org> - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @category Horde - * @package Translation - * @subpackage UnitTests - */ -class Horde_Translation_TestBase extends PHPUnit_Framework_TestCase -{ - private $_env; - - public function setUp() - { - try { - $this->setLocale(LC_ALL, 'de_DE.UTF-8'); - } catch (PHPUnit_Framework_Exception $e) { - $this->markTestSkipped('Setting the locale failed. de_DE.UTF-8 might not be supported.'); - } - $this->_setEnv('de_DE.UTF-8'); - } - - public function tearDown() - { - $this->_restoreEnv(); - } - - private function _setEnv($value) - { - foreach (array('LC_ALL', 'LANG', 'LANGUAGE') as $env) { - $this->_env[$env] = getenv($env); - putenv($env . '=' . $value); - } - } - - private function _restoreEnv() - { - foreach (array('LC_ALL', 'LANG', 'LANGUAGE') as $env) { - putenv($env . '=' . $this->_env[$env]); - } - } -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.0/test/Horde/Translation/WrapperTest.php new/Horde_Translation-1.0.0/test/Horde/Translation/WrapperTest.php --- old/Horde_Translation-1.0.0/test/Horde/Translation/WrapperTest.php 2011-04-06 01:22:32.000000000 +0200 +++ new/Horde_Translation-1.0.0/test/Horde/Translation/WrapperTest.php 1970-01-01 01:00:00.000000000 +0100 @@ -1,54 +0,0 @@ -<?php - -require_once dirname(__FILE__) . '/TestBase.php'; - -/** - * @author Jan Schneider <jan@horde.org> - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @category Horde - * @package Translation - * @subpackage UnitTests - */ -class Horde_Translation_WrapperTest extends Horde_Translation_TestBase -{ - public function testWrappers() - { - $this->assertEquals('Heute', Horde_Translation_TestWrapperA::t('Today')); - $this->assertEquals('1 Woche', sprintf(Horde_Translation_TestWrapperA::ngettext('%d week', '%d weeks', 1), 1)); - $this->assertEquals('Morgen', Horde_Translation_TestWrapperB::t('Tomorrow')); - } -} - -class Horde_Translation_TestWrapperA extends Horde_Translation -{ - static public function t($message) - { - self::$_domain = 'Horde_Translation'; - self::$_directory = dirname(__FILE__) . '/locale'; - return parent::t($message); - } - - static public function ngettext($singular, $plural, $number) - { - self::$_domain = 'Horde_Translation'; - self::$_directory = dirname(__FILE__) . '/locale'; - return parent::ngettext($singular, $plural, $number); - } -} - -class Horde_Translation_TestWrapperB extends Horde_Translation -{ - static public function t($message) - { - self::$_domain = 'Horde_Other'; - self::$_directory = dirname(__FILE__) . '/locale'; - return parent::t($message); - } - - static public function ngettext($singular, $plural, $number) - { - self::$_domain = 'Horde_Other'; - self::$_directory = dirname(__FILE__) . '/locale'; - return parent::ngettext($singular, $plural, $number); - } -} Files old/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.mo and new/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.mo differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.po new/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.po --- old/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.po 2011-04-06 01:22:32.000000000 +0200 +++ new/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.po 1970-01-01 01:00:00.000000000 +0100 @@ -1,18 +0,0 @@ -# German test translation for Horde_Translation. -# Copyright 2010-2011 The Horde Project (http://www.horde.org/) -# Jan Schneider <jan@horde.org>, 2010. -msgid "" -msgstr "" -"Project-Id-Version: Horde_Translation\n" -"Report-Msgid-Bugs-To: dev@lists.horde.org\n" -"POT-Creation-Date: 2010-08-17 18:32+0200\n" -"PO-Revision-Date: 2010-10-13 00:48+0200\n" -"Last-Translator: Jan Schneider <jan@horde.org>\n" -"Language-Team: German <dev@lists.horde.org>\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8-bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -msgid "Tomorrow" -msgstr "Morgen" Files old/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.mo and new/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.mo differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po new/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po --- old/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po 2011-04-06 01:22:32.000000000 +0200 +++ new/Horde_Translation-1.0.0/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po 1970-01-01 01:00:00.000000000 +0100 @@ -1,31 +0,0 @@ -# German test translation for Horde_Translation. -# Copyright 2010-2011 The Horde Project (http://www.horde.org/) -# Jan Schneider <jan@horde.org>, 2010. -msgid "" -msgstr "" -"Project-Id-Version: Horde_Translation\n" -"Report-Msgid-Bugs-To: dev@lists.horde.org\n" -"POT-Creation-Date: 2010-08-17 18:32+0200\n" -"PO-Revision-Date: 2010-08-25 13:24+0200\n" -"Last-Translator: Jan Schneider <jan@horde.org>\n" -"Language-Team: German <dev@lists.horde.org>\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8-bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -msgid "Today" -msgstr "Heute" - -msgid "Beautiful" -msgstr "Schön" - -#, php-format -msgid "%d days" -msgstr "%d Tage" - -#, php-format -msgid "%d week" -msgid_plural "%d weeks" -msgstr[0] "%d Woche" -msgstr[1] "%d Wochen" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.1/lib/Horde/Translation/Exception.php new/Horde_Translation-1.0.1/lib/Horde/Translation/Exception.php --- old/Horde_Translation-1.0.1/lib/Horde/Translation/Exception.php 1970-01-01 01:00:00.000000000 +0100 +++ new/Horde_Translation-1.0.1/lib/Horde/Translation/Exception.php 2011-07-27 16:53:52.000000000 +0200 @@ -0,0 +1,15 @@ +<?php +/** + * Exception class for Horde_Translation. + * + * Copyright 2010-2011 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Jan Schneider <jan@horde.org> + * @package Translation + */ +class Horde_Translation_Exception extends Exception +{ +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.1/lib/Horde/Translation/Handler/Gettext.php new/Horde_Translation-1.0.1/lib/Horde/Translation/Handler/Gettext.php --- old/Horde_Translation-1.0.1/lib/Horde/Translation/Handler/Gettext.php 1970-01-01 01:00:00.000000000 +0100 +++ new/Horde_Translation-1.0.1/lib/Horde/Translation/Handler/Gettext.php 2011-07-27 16:53:52.000000000 +0200 @@ -0,0 +1,82 @@ +<?php +/** + * @package Translation + * + * Copyright 2010-2011 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + */ + +/** + * The Horde_Translation_Handler_Gettext provides translations through the + * gettext extension, but fails gracefully if gettext is not installed. + * + * @author Jan Schneider <jan@horde.org> + * @package Translation + */ +class Horde_Translation_Handler_Gettext implements Horde_Translation_Handler +{ + /** + * The translation domain, e.g. package name. + * + * @var string + */ + protected $_domain; + + /** + * Whether the gettext extension is installed. + * + * @var boolean + */ + protected $_gettext; + + /** + * Constructor. + * + * @param string $domain The translation domain, e.g. package name. + * @param string $path The path to the gettext catalog. + */ + public function __construct($domain, $path) + { + if (!is_dir($path)) { + throw new InvalidArgumentException("$path is not a directory"); + } + $this->_gettext = function_exists('_'); + if (!$this->_gettext) { + return; + } + $this->_domain = $domain; + bindtextdomain($this->_domain, $path); + } + + /** + * Returns the translation of a message. + * + * @param string $message The string to translate. + * + * @return string The string translation, or the original string if no + * translation exists. + */ + public function t($message) + { + return $this->_gettext ? dgettext($this->_domain, $message) : $message; + } + + /** + * Returns the plural translation of a message. + * + * @param string $singular The singular version to translate. + * @param string $plural The plural version to translate. + * @param integer $number The number that determines singular vs. plural. + * + * @return string The string translation, or the original string if no + * translation exists. + */ + public function ngettext($singular, $plural, $number) + { + return $this->_gettext + ? dngettext($this->_domain, $singular, $plural, $number) + : ($number > 1 ? $plural : $singular); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.1/lib/Horde/Translation/Handler.php new/Horde_Translation-1.0.1/lib/Horde/Translation/Handler.php --- old/Horde_Translation-1.0.1/lib/Horde/Translation/Handler.php 1970-01-01 01:00:00.000000000 +0100 +++ new/Horde_Translation-1.0.1/lib/Horde/Translation/Handler.php 2011-07-27 16:53:52.000000000 +0200 @@ -0,0 +1,41 @@ +<?php +/** + * @package Translation + * + * Copyright 2010-2011 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + */ + +/** + * The Horde_Translation_Handler interface defines the interface for any + * classes providing translations. + * + * @author Jan Schneider <jan@horde.org> + * @package Translation + */ +interface Horde_Translation_Handler +{ + /** + * Returns the translation of a message. + * + * @var string $message The string to translate. + * + * @return string The string translation, or the original string if no + * translation exists. + */ + public function t($message); + + /** + * Returns the plural translation of a message. + * + * @param string $singular The singular version to translate. + * @param string $plural The plural version to translate. + * @param integer $number The number that determines singular vs. plural. + * + * @return string The string translation, or the original string if no + * translation exists. + */ + public function ngettext($singular, $plural, $number); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.1/lib/Horde/Translation.php new/Horde_Translation-1.0.1/lib/Horde/Translation.php --- old/Horde_Translation-1.0.1/lib/Horde/Translation.php 1970-01-01 01:00:00.000000000 +0100 +++ new/Horde_Translation-1.0.1/lib/Horde/Translation.php 2011-07-27 16:53:52.000000000 +0200 @@ -0,0 +1,111 @@ +<?php +/** + * @package Translation + * + * Copyright 2010-2011 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + */ + +/** + * Horde_Translation is the base class for any translation wrapper classes in + * libraries that want to utilize the Horde_Translation library for + * translations. + * + * @author Jan Schneider <jan@horde.org> + * @package Translation + */ +abstract class Horde_Translation +{ + /** + * The translation domain, e.g. the library name, for the default gettext + * handler. + * + * @var string + */ + static protected $_domain; + + /** + * The relative path to the translations for the default gettext handler. + * + * This path is relative to the + * + * @var string + */ + static protected $_directory; + + /** + * The handlers providing the actual translations. + * + * @var array + */ + static protected $_handlers = array(); + + /** + * Loads a translation handler class pointing to the library's translations + * and assigns it to $_handler. + * + * @param string $handlerClass The name of a class implementing the + * Horde_Translation_Handler interface. + */ + static public function loadHandler($handlerClass) + { + if (!self::$_domain || !self::$_directory) { + throw new Horde_Translation_Exception('The domain and directory properties must be set by the class that extends Horde_Translation.'); + } + self::setHandler(self::$_domain, new $handlerClass(self::$_domain, self::$_directory)); + } + + /** + * Assigns a translation handler object to $_handlers. + * + * Type hinting isn't used on purpose. You should extend a custom + * translation handler passed here from the Horde_Translation interface, + * but technically it's sufficient if you provide the API of that + * interface. + * + * @param string $domain The translation domain. + * @param Horde_Translation_Handler $handler An object implementing the + * Horde_Translation_Handler + * interface. + */ + static public function setHandler($domain, $handler) + { + self::$_handlers[$domain] = $handler; + } + + /** + * Returns the translation of a message. + * + * @var string $message The string to translate. + * + * @return string The string translation, or the original string if no + * translation exists. + */ + static public function t($message) + { + if (!isset(self::$_handlers[self::$_domain])) { + self::loadHandler('Horde_Translation_Handler_Gettext'); + } + return self::$_handlers[self::$_domain]->t($message); + } + + /** + * Returns the plural translation of a message. + * + * @param string $singular The singular version to translate. + * @param string $plural The plural version to translate. + * @param integer $number The number that determines singular vs. plural. + * + * @return string The string translation, or the original string if no + * translation exists. + */ + static public function ngettext($singular, $plural, $number) + { + if (!isset(self::$_handlers[self::$_domain])) { + self::loadHandler('Horde_Translation_Handler_Gettext'); + } + return self::$_handlers[self::$_domain]->ngettext($singular, $plural, $number); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.1/test/Horde/Translation/AllTests.php new/Horde_Translation-1.0.1/test/Horde/Translation/AllTests.php --- old/Horde_Translation-1.0.1/test/Horde/Translation/AllTests.php 1970-01-01 01:00:00.000000000 +0100 +++ new/Horde_Translation-1.0.1/test/Horde/Translation/AllTests.php 2011-07-27 16:53:52.000000000 +0200 @@ -0,0 +1,36 @@ +<?php +/** + * Horde_Translation test suite. + * + * @author Jan Schneider <jan@horde.org> + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @category Horde + * @package Translation + * @subpackage UnitTests + */ + +/** + * Define the main method + */ +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Horde_Translation_AllTests::main'); +} + +/** + * Prepare the test setup. + */ +require_once 'Horde/Test/AllTests.php'; + +/** + * @package Translation + * @subpackage UnitTests + */ +class Horde_Translation_AllTests extends Horde_Test_AllTests +{ +} + +Horde_Translation_AllTests::init('Horde_Translation', __FILE__); + +if (PHPUnit_MAIN_METHOD == 'Horde_Translation_AllTests::main') { + Horde_Translation_AllTests::main(); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.1/test/Horde/Translation/GettextTest.php new/Horde_Translation-1.0.1/test/Horde/Translation/GettextTest.php --- old/Horde_Translation-1.0.1/test/Horde/Translation/GettextTest.php 1970-01-01 01:00:00.000000000 +0100 +++ new/Horde_Translation-1.0.1/test/Horde/Translation/GettextTest.php 2011-07-27 16:53:52.000000000 +0200 @@ -0,0 +1,49 @@ +<?php + +require_once dirname(__FILE__) . '/TestBase.php'; + +/** + * @author Jan Schneider <jan@horde.org> + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @category Horde + * @package Translation + * @subpackage UnitTests + */ +class Horde_Translation_GettextTest extends Horde_Translation_TestBase +{ + private $_dict; + private $_otherDict; + + public function setUp() + { + parent::setUp(); + $this->_dict = new Horde_Translation_Handler_Gettext('Horde_Translation', dirname(__FILE__) . '/locale'); + $this->_otherDict = new Horde_Translation_Handler_Gettext('Horde_Other', dirname(__FILE__) . '/locale'); + } + + public function testGettext() + { + $this->assertEquals('Heute', $this->_dict->t('Today')); + $this->assertEquals('Schön', $this->_dict->t('Beautiful')); + $this->assertEquals('2 Tage', sprintf($this->_dict->t('%d days'), 2)); + $this->assertEquals('Morgen', $this->_otherDict->t('Tomorrow')); + } + + public function testNgettext() + { + $this->assertEquals('1 Woche', sprintf($this->_dict->ngettext('%d week', '%d weeks', 1), 1)); + $this->assertEquals('2 Wochen', sprintf($this->_dict->ngettext('%d week', '%d weeks', 2), 2)); + } + + public function testInvalidConstruction() + { + try { + new Horde_Translation_Handler_Gettext('Horde_Translation', dirname(__FILE__) . '/DOES_NOT_EXIST'); + } catch (InvalidArgumentException $e) { + $this->assertEquals( + dirname(__FILE__) . '/DOES_NOT_EXIST is not a directory', + $e->getMessage() + ); + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.1/test/Horde/Translation/TestBase.php new/Horde_Translation-1.0.1/test/Horde/Translation/TestBase.php --- old/Horde_Translation-1.0.1/test/Horde/Translation/TestBase.php 1970-01-01 01:00:00.000000000 +0100 +++ new/Horde_Translation-1.0.1/test/Horde/Translation/TestBase.php 2011-07-27 16:53:52.000000000 +0200 @@ -0,0 +1,42 @@ +<?php +/** + * @author Jan Schneider <jan@horde.org> + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @category Horde + * @package Translation + * @subpackage UnitTests + */ +class Horde_Translation_TestBase extends PHPUnit_Framework_TestCase +{ + private $_env; + + public function setUp() + { + try { + $this->setLocale(LC_ALL, 'de_DE.UTF-8'); + } catch (PHPUnit_Framework_Exception $e) { + $this->markTestSkipped('Setting the locale failed. de_DE.UTF-8 might not be supported.'); + } + $this->_setEnv('de_DE.UTF-8'); + } + + public function tearDown() + { + $this->_restoreEnv(); + } + + private function _setEnv($value) + { + foreach (array('LC_ALL', 'LANG', 'LANGUAGE') as $env) { + $this->_env[$env] = getenv($env); + putenv($env . '=' . $value); + } + } + + private function _restoreEnv() + { + foreach (array('LC_ALL', 'LANG', 'LANGUAGE') as $env) { + putenv($env . '=' . $this->_env[$env]); + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.1/test/Horde/Translation/WrapperTest.php new/Horde_Translation-1.0.1/test/Horde/Translation/WrapperTest.php --- old/Horde_Translation-1.0.1/test/Horde/Translation/WrapperTest.php 1970-01-01 01:00:00.000000000 +0100 +++ new/Horde_Translation-1.0.1/test/Horde/Translation/WrapperTest.php 2011-07-27 16:53:52.000000000 +0200 @@ -0,0 +1,54 @@ +<?php + +require_once dirname(__FILE__) . '/TestBase.php'; + +/** + * @author Jan Schneider <jan@horde.org> + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @category Horde + * @package Translation + * @subpackage UnitTests + */ +class Horde_Translation_WrapperTest extends Horde_Translation_TestBase +{ + public function testWrappers() + { + $this->assertEquals('Heute', Horde_Translation_TestWrapperA::t('Today')); + $this->assertEquals('1 Woche', sprintf(Horde_Translation_TestWrapperA::ngettext('%d week', '%d weeks', 1), 1)); + $this->assertEquals('Morgen', Horde_Translation_TestWrapperB::t('Tomorrow')); + } +} + +class Horde_Translation_TestWrapperA extends Horde_Translation +{ + static public function t($message) + { + self::$_domain = 'Horde_Translation'; + self::$_directory = dirname(__FILE__) . '/locale'; + return parent::t($message); + } + + static public function ngettext($singular, $plural, $number) + { + self::$_domain = 'Horde_Translation'; + self::$_directory = dirname(__FILE__) . '/locale'; + return parent::ngettext($singular, $plural, $number); + } +} + +class Horde_Translation_TestWrapperB extends Horde_Translation +{ + static public function t($message) + { + self::$_domain = 'Horde_Other'; + self::$_directory = dirname(__FILE__) . '/locale'; + return parent::t($message); + } + + static public function ngettext($singular, $plural, $number) + { + self::$_domain = 'Horde_Other'; + self::$_directory = dirname(__FILE__) . '/locale'; + return parent::ngettext($singular, $plural, $number); + } +} Files old/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.mo and new/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.mo differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.po new/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.po --- old/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.po 1970-01-01 01:00:00.000000000 +0100 +++ new/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.po 2011-07-27 16:53:52.000000000 +0200 @@ -0,0 +1,18 @@ +# German test translation for Horde_Translation. +# Copyright 2010-2011 The Horde Project (http://www.horde.org/) +# Jan Schneider <jan@horde.org>, 2010. +msgid "" +msgstr "" +"Project-Id-Version: Horde_Translation\n" +"Report-Msgid-Bugs-To: dev@lists.horde.org\n" +"POT-Creation-Date: 2010-08-17 18:32+0200\n" +"PO-Revision-Date: 2010-10-13 00:48+0200\n" +"Last-Translator: Jan Schneider <jan@horde.org>\n" +"Language-Team: German <dev@lists.horde.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8-bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "Tomorrow" +msgstr "Morgen" Files old/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.mo and new/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.mo differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po new/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po --- old/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po 1970-01-01 01:00:00.000000000 +0100 +++ new/Horde_Translation-1.0.1/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po 2011-07-27 16:53:52.000000000 +0200 @@ -0,0 +1,31 @@ +# German test translation for Horde_Translation. +# Copyright 2010-2011 The Horde Project (http://www.horde.org/) +# Jan Schneider <jan@horde.org>, 2010. +msgid "" +msgstr "" +"Project-Id-Version: Horde_Translation\n" +"Report-Msgid-Bugs-To: dev@lists.horde.org\n" +"POT-Creation-Date: 2010-08-17 18:32+0200\n" +"PO-Revision-Date: 2010-08-25 13:24+0200\n" +"Last-Translator: Jan Schneider <jan@horde.org>\n" +"Language-Team: German <dev@lists.horde.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8-bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "Today" +msgstr "Heute" + +msgid "Beautiful" +msgstr "Schön" + +#, php-format +msgid "%d days" +msgstr "%d Tage" + +#, php-format +msgid "%d week" +msgid_plural "%d weeks" +msgstr[0] "%d Woche" +msgstr[1] "%d Wochen" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/package.xml new/package.xml --- old/package.xml 2011-04-06 01:22:32.000000000 +0200 +++ new/package.xml 2011-07-27 16:53:52.000000000 +0200 @@ -1,19 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> -<package packagerversion="1.9.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> +<package packagerversion="1.9.3" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>Horde_Translation</name> <channel>pear.horde.org</channel> <summary>Horde translation library</summary> - <description>.</description> + <description>Translation wrappers.</description> <lead> <name>Jan Schneider</name> <user>jan</user> <email>jan@horde.org</email> <active>yes</active> </lead> - <date>2011-04-06</date> - <time>01:22:32</time> + <date>2011-07-27</date> + <time>16:53:52</time> <version> - <release>1.0.0</release> + <release>1.0.1</release> <api>1.0.0</api> </version> <stability> @@ -22,12 +22,12 @@ </stability> <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license> <notes> -* First stable release for Horde 4. +* [cjh] Don't extend Horde_Translation_Exception from Horde_Exception_Wrapped to avoid circular dependency. </notes> <contents> <dir baseinstalldir="/" name="/"> <file baseinstalldir="/" md5sum="d860f9cb5e347b1d3d0d3a20259f2118" name="lib/Horde/Translation/Handler/Gettext.php" role="php" /> - <file baseinstalldir="/" md5sum="6ce62258226a49c1d0a9dd8f33a0836a" name="lib/Horde/Translation/Exception.php" role="php" /> + <file baseinstalldir="/" md5sum="b49a863dff4a37349ab3054940bd6246" name="lib/Horde/Translation/Exception.php" role="php" /> <file baseinstalldir="/" md5sum="b90d808eccc61a8d01ff0287a24aa6f8" name="lib/Horde/Translation/Handler.php" role="php" /> <file baseinstalldir="/" md5sum="4db71784554c232b0845a6e410bda7ce" name="lib/Horde/Translation.php" role="php" /> <file baseinstalldir="/" md5sum="e7833d342dd9fc3648257ebf2d4ad416" name="test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Other.mo" role="test" /> @@ -48,13 +48,6 @@ <pearinstaller> <min>1.7.0</min> </pearinstaller> - <package> - <name>Horde_Exception</name> - <channel>pear.horde.org</channel> - <min>1.0.0</min> - <max>2.0.0</max> - <exclude>2.0.0</exclude> - </package> </required> <optional> <package> @@ -161,5 +154,20 @@ * First stable release for Horde 4. </notes> </release> + <release> + <version> + <release>1.0.1</release> + <api>1.0.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2011-07-27</date> + <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license> + <notes> +* [cjh] Don't extend Horde_Translation_Exception from Horde_Exception_Wrapped to avoid circular dependency. + </notes> + </release> </changelog> </package> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org