{
private $_dict;
private $_otherDict;
+ private $_env;
public function setUp()
{
- putenv('LC_ALL=de_DE.UTF-8');
- putenv('LANG=de_DE.UTF-8');
- putenv('LANGUAGE=de_DE.UTF-8');
+ 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');
$this->_dict = new Horde_Translation_Gettext('Horde_Translation', dirname(__FILE__) . '/locale');
$this->_otherDict = new Horde_Translation_Gettext('Horde_Other', dirname(__FILE__) . '/locale');
}
+ public function tearDown()
+ {
+ $this->_restoreEnv();
+ }
+
public function testGettext()
{
$this->assertEquals('Heute', $this->_dict->t('Today'));
$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));
}
+
+ 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]);
+ }
+ }
}