Exemplo n.º 1
0
 public function testIsTranslated()
 {
     $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)',
                                                       'msg2' => 'Message 2 (en)',
                                                       'msg3' => 'Message 3 (en)',
                                                      ));
     $this->assertTrue( $adapter->isTranslated('msg1'));
     $this->assertFalse($adapter->isTranslated('msg4'));
 }
Exemplo n.º 2
0
 /**
  * @param string $string
  * @return string
  */
 public function translate($string)
 {
     if (strlen($string) == 0) {
         return '';
     }
     $translation = $this->_translation_engine->translate($string, $this->locale);
     $is_translated = $this->_translation_engine->isTranslated($string, $this->locale);
     p4a::singleton()->actionHandler('ontranslate', $string, $translation, $is_translated);
     return $translation;
 }
 public function testIsTranslated()
 {
     $adapter = new Zend_Translate_Adapter_Array(dirname(__FILE__) . '/_files/translation_en.php', 'en');
     $this->assertTrue($adapter->isTranslated('Message 1'));
     $this->assertFalse($adapter->isTranslated('Message 6'));
     $this->assertTrue($adapter->isTranslated('Message 1', true));
     $this->assertFalse($adapter->isTranslated('Message 1', true, 'en_US'));
     $this->assertTrue($adapter->isTranslated('Message 1', false, 'en_US'));
     $this->assertFalse($adapter->isTranslated('Message 1', false, 'es'));
     $this->assertFalse($adapter->isTranslated('Message 1', 'es'));
     $this->assertFalse($adapter->isTranslated('Message 1', 'xx_XX'));
     $this->assertTrue($adapter->isTranslated('Message 1', 'en_XX'));
 }