示例#1
0
 public function init()
 {
     $bootstrap = $this->getBootstrap();
     $bootstrap->bootstrap('Config');
     $config = $bootstrap->getResource('Config');
     $locale = $config->locale;
     if ($locale instanceof Zend_Config) {
         $localeName = $locale->name;
         $cache = $locale->cache;
     } else {
         $localeName = $locale;
         $cache = null;
     }
     if ($this->getBootstrap()->hasResource('Pluginbroker')) {
         $broker = $this->getBootstrap()->getResource('Pluginbroker');
         $localeName = $broker->applyFilters('locale', $localeName);
     }
     if ($cache === null) {
         $cache = 'locale';
     }
     $this->setOptions(array('cache' => $cache));
     if ($localeName) {
         $this->setOptions(array('default' => $localeName));
         $this->_setTranslate($localeName, $cache);
     }
     $locale = parent::init();
     if ($cache === '') {
         $locale->disableCache(true);
     }
     return $locale;
 }
示例#2
0
文件: LocaleTest.php 项目: hjr3/zf2
 public function testOptionsPassedToResourceAreUsedToSetLocaleState1()
 {
     $options = array('default' => 'kok_IN');
     $resource = new Zend_Application_Resource_Locale($options);
     $resource->setBootstrap($this->bootstrap);
     $resource->init();
     $locale = $resource->getLocale();
     // This test will fail if your configured locale is kok_IN
     $this->assertFalse('kok_IN' == $locale->__toString());
     $this->assertSame(Zend_Registry::get('Zend_Locale'), $locale);
 }
示例#3
0
 /**
  * @group ZF-7058
  */
 public function testSetCacheFromCacheManager()
 {
     $configCache = array('memory' => array('frontend' => array('name' => 'Core', 'options' => array('lifetime' => 120, 'automatic_serialization' => true)), 'backend' => array('name' => 'Black Hole')));
     $this->bootstrap->registerPluginResource('cachemanager', $configCache);
     $this->assertFalse(Zend_Locale::hasCache());
     $config = array('bootstrap' => $this->bootstrap, 'cache' => 'memory');
     $resource = new Zend_Application_Resource_Locale($config);
     $resource->init();
     $this->assertTrue(Zend_Locale::hasCache());
     Zend_Locale::removeCache();
 }
示例#4
0
 protected function _initLocale()
 {
     $options = Zend_Json::decode(Tri_Config::get('locale'));
     $resource = new Zend_Application_Resource_Locale($options);
     $resource->init();
 }