Exemplo n.º 1
0
 public function testLocale()
 {
     $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)', 'msg2' => 'Message 2 (en)', 'msg3' => 'Message 3 (en)'), 'en');
     $this->assertEquals($adapter->getLocale(), 'en');
     $locale = new Zend_Locale('en');
     $adapter->setLocale($locale);
     $this->assertEquals($adapter->getLocale(), 'en');
     try {
         $adapter->setLocale('nolocale');
         $this->fail();
     } catch (Zend_Translate_Exception $e) {
         // success
     }
     try {
         $adapter->setLocale('de');
         $this->fail();
     } catch (Zend_Translate_Exception $e) {
         // success
     }
 }
 public function testLocale()
 {
     $adapter = new Zend_Translate_Adapter_Array(dirname(__FILE__) . '/_files/translation_en.php', 'en');
     $this->assertEquals('en', $adapter->getLocale());
     $locale = new Zend_Locale('en');
     $adapter->setLocale($locale);
     $this->assertEquals('en', $adapter->getLocale());
     try {
         $adapter->setLocale('nolocale');
         $this->fail("exception expected");
     } catch (Zend_Translate_Exception $e) {
         $this->assertContains('does not exist', $e->getMessage());
     }
     set_error_handler(array($this, 'errorHandlerIgnore'));
     $adapter->setLocale('de');
     restore_error_handler();
     $this->assertEquals('de', $adapter->getLocale());
 }