Ejemplo n.º 1
0
 protected function _initTranslate()
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . "/configs/gasestema.ini");
     $resource = new Zend_Application_Resource_Translate(array('adapter' => 'gettext', 'locale' => $config->locale, 'data' => APPLICATION_PATH . "/translations/{$config->locale}.mo", 'options' => array('disableNotices' => true)));
     $resource->setBootstrap($this);
     return $resource->init();
 }
Ejemplo n.º 2
0
 public function init()
 {
     $options = $this->getOptions();
     //reset content options
     if (isset($options['locale']) && isset($options['content']) && isset($options['fileExt'])) {
         //get locale data
         $session = new Zend_Session_Namespace('RFLib');
         if ($session->locale) {
             $locale = $session->locale;
         } else {
             $locale = $options['locale'];
         }
         $options['content'] = $options['content'] . DS . $locale . $options['fileExt'];
     }
     $this->setOptions($options);
     parent::init();
 }
Ejemplo n.º 3
0
 public function init()
 {
     parent::init();
     $modules = Zend_Registry::get('modules');
     foreach ($modules as &$path) {
         if (is_dir($path . DS . 'Locales')) {
             $files = glob($path . DS . 'Locales' . DS . '*.*');
             if (sizeof($files)) {
                 foreach ($files as $file) {
                     //$name = basename($file);
                     //list($locale, $extension) = explode('.', $name);
                     $this->_translate->addTranslation(array('content' => $file, 'locale' => 'auto'));
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @group GH-103
  */
 public function testLogFactory()
 {
     $options = $this->_translationOptions;
     $options['log'][0] = new Zend_Log_Writer_Mock();
     $options['logUntranslated'] = true;
     $options['locale'] = 'en';
     $resource = new Zend_Application_Resource_Translate($options);
     $resource->setBootstrap($this->bootstrap);
     $resource->init()->translate('untranslated');
     $event = current($options['log'][0]->events);
     $this->assertTrue(is_array($event));
     $this->assertTrue(array_key_exists('message', $event));
     $this->assertEquals("Untranslated message within 'en': untranslated", $event['message']);
 }
Ejemplo n.º 5
0
 /**
  * @group ZF-10352
  * @expectedException Zend_Application_Resource_Exception
  */
 public function testToUseTheTwoKeysContentAndDataShouldThrowsException()
 {
     $options = array('adapter' => 'array', 'content' => array('m1' => 'message1', 'm2' => 'message2'), 'data' => array('m3' => 'message3', 'm4' => 'message4'), 'locale' => 'auto');
     $resource = new Zend_Application_Resource_Translate($options);
     $translator = $resource->init();
 }
Ejemplo n.º 6
0
 public function testOptionsPassedToResourceAreUsedToSetLocaleState()
 {
     $resource = new Zend_Application_Resource_Translate($this->_translationOptions);
     $resource->setBootstrap($this->bootstrap);
     $resource->init();
     $translate = $resource->getTranslate();
     $this->assertTrue(Zend_Registry::isRegistered('Zend_Translate'));
     $this->assertSame(Zend_Registry::get('Zend_Translate'), $translate);
 }
Ejemplo n.º 7
0
 protected function _initTranslate()
 {
     $options = Zend_Json::decode(Tri_Config::get('translate'));
     $resource = new Zend_Application_Resource_Translate($options);
     $resource->init();
 }