public function testLoadTranslationData() { $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)', 'msg2' => 'Message 2 (en)', 'msg3' => 'Message 3 (en)', ), 'en'); $this->assertEquals($adapter->translate('msg1'), 'Message 1 (en)'); $this->assertEquals($adapter->_('msg1'), 'Message 1 (en)'); $this->assertEquals($adapter->translate('msg4'), 'msg4'); $adapter->addTranslation(array('msg4' => 'Message 4 (en)', 'msg5' => 'Message 5 (en)', 'msg6' => 'Message 6 (en)' ),'en'); $this->assertEquals($adapter->translate('msg5'), 'Message 5 (en)'); $adapter->addTranslation(array('msg1' => 'Message 1 (ru)', 'msg2' => 'Message 2 (ru)', 'msg3' => 'Message 3 (ru)' ), 'ru'); $this->assertEquals($adapter->translate('msg1', 'ru'), 'Message 1 (ru)'); $adapter->addTranslation(array('msg4' => 'Message 4 (ru)', 'msg5' => 'Message 5 (ru)', 'msg6' => 'Message 6 (ru)' ), 'ru', array('clear' => true)); $this->assertEquals($adapter->translate('msg2', 'ru'), 'msg2'); $this->assertEquals($adapter->translate('msg4', 'ru'), 'Message 4 (ru)'); $this->assertEquals($adapter->translate('msg1', 'xx'), 'msg1'); $this->assertEquals($adapter->translate('msg4', 'ru_RU'), 'Message 4 (ru)'); try { $adapter->addTranslation(array('msg1' => 'Message 1 (ru)', 'msg2' => 'Message 2 (ru)', 'msg3' => 'Message 3 (ru)' ), 'xx'); $this->fail(); } catch (Zend_Translate_Exception $e) { // success } }
public function testTranslate() { $adapter = new Zend_Translate_Adapter_Array(dirname(__FILE__) . '/_files/translation_en.php', 'en'); $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1')); $this->assertEquals('Message 1 (en)', $adapter->_('Message 1')); $this->assertEquals('Message 6', $adapter->translate('Message 6')); $this->assertEquals('Küchen Möbel (en)', $adapter->translate('Cooking furniture')); $this->assertEquals('Cooking furniture (en)', $adapter->translate('Küchen Möbel')); }