当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Translate::setCache方法代码示例

本文整理汇总了PHP中Zend_Translate::setCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Translate::setCache方法的具体用法?PHP Zend_Translate::setCache怎么用?PHP Zend_Translate::setCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Translate的用法示例。


在下文中一共展示了Zend_Translate::setCache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 /**
  * Retrieve service object instance
  *
  * @param Zend_Config $config
  * @return Zend_Translate
  */
 public function &getService($config)
 {
     if (!$this->service) {
         Zend_Translate::setCache(Zoo::getService('cache')->getCache('translate'));
         /*
          * @todo Re-enable this with configuration options instead of hardcoding
         $writer = new Zend_Log_Writer_Firebug();
         			$logger = new Zend_Log($writer);
         $this->service = new Zend_Translate('gettext',
                                             ZfApplication::$_base_path."/app/Zoo/Language",
                                             null,
                                             array(
                                                   'scan' => Zend_Translate::LOCALE_FILENAME,
                                                   'disableNotices' => true, 
                                             	  'log' => $logger,
                                             	  'logUntranslated' => true)
                                             );
         */
         if ($config->language->default) {
             $locale = new Zend_Locale($config->language->default);
             Zend_Registry::set("Zend_Locale", $locale);
         } else {
             $locale = new Zend_Locale("en");
         }
         $this->service = new Zend_Translate('gettext', ZfApplication::$_base_path . "/app/Zoo/Language", $locale, array('scan' => Zend_Translate::LOCALE_FILENAME, 'disableNotices' => true));
     }
     return $this->service;
 }
开发者ID:BGCX261,项目名称:zoocms-svn-to-git,代码行数:34,代码来源:Translator.php

示例2: init

 public function init()
 {
     if (null === $this->_cache) {
         $options = $this->getOptions();
         if (!isset($options[0]) && $options) {
             if (!isset($options['frontend']['adapter'])) {
                 $options['frontend']['adapter'] = 'Core';
             }
             if (!isset($options['backend']['adapter'])) {
                 $options['backend']['adapter'] = 'Memcached';
             }
             if (!isset($options['frontend']['params'])) {
                 $options['frontend']['params'] = array();
             }
             if (!isset($options['backend']['params'])) {
                 $options['backend']['params'] = array();
             }
             $this->_cache = Zend_Cache::factory($options['frontend']['adapter'], $options['backend']['adapter'], $options['frontend']['params'], $options['backend']['params']);
             if (isset($options['metadata']) && true === (bool) $options['metadata']) {
                 Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
             }
             if (isset($options['translate']) && true === (bool) $options['translate']) {
                 Zend_Translate::setCache($this->_cache);
             }
             if (isset($options['locale']) && true === (bool) $options['locale']) {
                 Zend_Locale::setCache($this->_cache);
             }
         } else {
             $this->_cache = false;
         }
         $key = isset($options['registry']) && !is_numeric($options['registry']) ? $options['registry'] : self::DEFAULT_REGISTRY_KEY;
         Zend_Registry::set($key, $this->_cache);
     }
     return $this->_cache;
 }
开发者ID:s-kalaus,项目名称:zkernel,代码行数:35,代码来源:Cache.php

示例3: initializeLocale

function initializeLocale($g_ui_locale)
{
    global $_, $_locale;
    if (!file_exists($vs_locale_path = __CA_APP_DIR__ . '/locale/user/' . $g_ui_locale . '/messages.mo')) {
        $vs_locale_path = __CA_APP_DIR__ . '/locale/' . $g_ui_locale . '/messages.mo';
    }
    if (file_exists($vs_locale_path)) {
        // If the locale is valid, locale is set
        $_locale = new Zend_Locale($g_ui_locale);
        Zend_Registry::set('Zend_Locale', $_locale);
        if (!caIsRunFromCLI() && ($o_cache = caGetCacheObject('ca_translation', 3600 * 24))) {
            Zend_Translate::setCache($o_cache);
        }
        $_ = new Zend_Translate(array('adapter' => 'gettext', 'content' => $vs_locale_path, 'locale' => $_locale, 'tag' => 'CA'));
        $cookiepath = __CA_URL_ROOT__ == "" ? "/" : __CA_URL_ROOT__;
        if (!headers_sent()) {
            setcookie('CA_' . __CA_APP_NAME__ . '_ui_locale', $g_ui_locale, time() + 36000, $cookiepath);
        }
        return true;
    } else {
        // cookie invalid, deleting
        if (!headers_sent()) {
            setcookie('CA_' . __CA_APP_NAME__ . '_ui_locale', NULL, -1);
        }
        return false;
    }
}
开发者ID:idiscussforum,项目名称:providence,代码行数:27,代码来源:initializeLocale.php

示例4: preDispatch

 public function preDispatch($request)
 {
     try {
         $locale = new Zend_Locale();
         $locale->setDefault('en');
         $locale->setLocale(Zend_Locale::BROWSER);
         $requestedLanguage = key($locale->getBrowser());
         $formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL);
         $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'translations.log');
         $writer->setFormatter($formatter);
         $logger = new Zend_Log($writer);
         $frontendOptions = array('cache_id_prefix' => 'translation', 'lifetime' => 86400, 'automatic_serialization' => true);
         $backendOptions = array('cache_dir' => APPLICATION_CACHE_PATH);
         $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
         $options = array('adapter' => 'gettext', 'scan' => Zend_Translate::LOCALE_FILENAME, 'content' => APPLICATION_PATH . '/languages/en/en.mo', 'locale' => 'auto', 'disableNotices' => true);
         $translate = new Zend_Translate($options);
         if (!$translate->isAvailable($locale->getLanguage())) {
             $locale->setLocale('en');
         } else {
             $translate->setLocale($locale);
         }
         $translate->setCache($cache);
         Zend_Registry::set('locale', $locale->getLanguage());
         Zend_Registry::set('Zend_Translate', $translate);
     } catch (Exception $e) {
         try {
             $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugin-locale.log');
             $logger = new Zend_Log($writer);
             $logger->log($e->getMessage(), Zend_Log::ERR);
         } catch (Exception $e) {
         }
     }
 }
开发者ID:rogercastaneda,项目名称:owlsys,代码行数:33,代码来源:Locale.php

示例5: init

 /**
  * To init the view
  *
  * @return Zend_View $view
  */
 public function init()
 {
     $frontendOptions = array('automatic_serialization' => true, 'lifetime' => 86400);
     $backendOptions = array('cache_dir' => PROJECT_ROOT . '/repository/cache/');
     if ('development' == APPLICATION_ENV) {
         $frontendOptions['caching'] = false;
         //关闭缓存
     } else {
         $classFileIncCache = $backendOptions['cache_dir'] . 'pluginLoaderCache.php';
         if (file_exists($classFileIncCache)) {
             include_once $classFileIncCache;
         }
         Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     }
     $this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
     //缓存Zend_Db_Table元数据
     Zend_Date::setOptions(array('cache' => $this->_cache));
     //缓存Zend_Date
     Zend_Translate::setCache($this->_cache);
     //缓存Zend_Translate
     Zend_Registry::set('cache', $this->_cache);
     // Return it, so that it can be stored by the bootstrap
     return $this->_cache;
 }
开发者ID:BGCX262,项目名称:zyk-svn-to-git,代码行数:30,代码来源:Cache.php

示例6: _initTranslation

 protected function _initTranslation()
 {
     $cache = $this->_getCache('core');
     Zend_Translate::setCache($cache);
     Zend_Date::setOptions(array('cache' => $cache));
     Zend_Paginator::setCache($cache);
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:7,代码来源:Bootstrap.php

示例7: _initTranslateCache

 protected function _initTranslateCache()
 {
     //$this->_bootstrap('cache');
     if (Zend_Registry::getInstance()->isRegistered(self::TRANSLATE_CACHE_REGISTRY_KEY)) {
         $translateCache = Zend_Registry::getInstance()->get(self::TRANSLATE_CACHE_REGISTRY_KEY);
         Zend_Translate::setCache($translateCache);
     }
 }
开发者ID:BGCX261,项目名称:zillatek-project-svn-to-git,代码行数:8,代码来源:Bootstrap.php

示例8: routeStartup

 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $backendOptions = array('cache_dir' => APPLICATION_PATH . '/../cache');
     $frontendOptions = array('caching' => Zend_Registry::getInstance()->get('Zend_Config')->get('cache', false) == false ? false : Zend_Registry::getInstance()->get('Zend_Config')->get('cache')->get('enabled', false), 'automatic_serialization' => true, 'lifetime' => null, 'automatic_serialization' => true);
     $translateCache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Translate::setCache($translateCache);
     $translate = new Zend_Translate(Zend_Translate::AN_ARRAY, APPLICATION_PATH . '/languages', null, array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     Zend_Registry::getInstance()->set('Zend_Translate', $translate);
 }
开发者ID:BackupTheBerlios,项目名称:dkplusengine,代码行数:9,代码来源:Translation.php

示例9: _initCache

 /**
  * Démarrage du gestionnaire de caches, on récupère chaque configuration.
  * Par défaut on met en cache les métadata de la bdd
  *
  * @return void.
  */
 protected function _initCache()
 {
     if ((bool) APP_CACHE) {
         // Récupération des ressources du gestionnaire du cache
         $this->bootstrap('cachemanager');
         // Activation du cache du Zend_Translate
         Zend_Translate::setCache($this->getResource('cachemanager')->getCache('translate'));
         // Activation du cache de la base de données
         Zend_Db_Table_Abstract::setDefaultMetadataCache($this->getResource('cachemanager')->getCache('default'));
     }
 }
开发者ID:netixx,项目名称:Stock,代码行数:17,代码来源:Bootstrap.php

示例10: _initTranslate

 protected function _initTranslate()
 {
     $frontendOptions = array('lifetime' => 60 * 60 * 24, 'automatic_serialization' => true);
     // время жизни кэша - 24 часа
     $cfg = $this->getOptions();
     $backendOptions = array('cache_dir' => $cfg['temp']['path']);
     // директория, в которой размещаются файлы кэша
     $cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions);
     Zend_Translate::setCache($cache);
     $translate = new Zend_Translate(Zend_Translate::AN_GETTEXT, APPLICATION_PATH . 'locales', 'auto', array('scan' => Zend_Translate::LOCALE_DIRECTORY, 'disableNotices' => true));
     Zend_Registry::set('Zend_Translate', $translate);
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:12,代码来源:Bootstrap.php

示例11: addSiteInterfaceLanguage

		public function addSiteInterfaceLanguage($language) {
			if (is_object($this->translate)) {
				$this->translate->addTranslation(DIR_LANGUAGES_SITE_INTERFACE . '/' . $language . '.mo', $language);
			} else {
				Loader::library('3rdparty/Zend/Translate');
				$cache = Cache::getLibrary();
				if (is_object($cache)) {
					Zend_Translate::setCache($cache);
				}
				$this->translate = new Zend_Translate(array('adapter' => 'gettext', 'content' => DIR_LANGUAGES_SITE_INTERFACE . '/' . $language . '.mo', 'locale' => $language, 'disableNotices' => true));
			}
		}
开发者ID:nbourguig,项目名称:concrete5,代码行数:12,代码来源:localization.php

示例12: _initZendCache

 /**
  * Setup zend cache directory.
  *
  * @return void
  */
 protected function _initZendCache()
 {
     $this->bootstrap('Configuration');
     $config = $this->getResource('Configuration');
     $frontendOptions = array('lifetime' => 600, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => $config->workspacePath . '/cache/');
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Translate::setCache($cache);
     Zend_Locale::setCache($cache);
     Zend_Locale_Data::setCache($cache);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     return $cache;
 }
开发者ID:alexukua,项目名称:opus4,代码行数:18,代码来源:Base.php

示例13: __construct

 public function __construct()
 {
     Loader::library('3rdparty/Zend/Date');
     Loader::library('3rdparty/Zend/Translate');
     Loader::library('3rdparty/Zend/Locale');
     Loader::library('3rdparty/Zend/Locale/Data');
     $cache = Cache::getLibrary();
     if (is_object($cache)) {
         Zend_Translate::setCache($cache);
         Zend_Date::setOptions(array('cache' => $cache));
     }
     $locale = defined('ACTIVE_LOCALE') ? ACTIVE_LOCALE : 'en_US';
     $this->setLocale($locale);
     Zend_Date::setOptions(array('format_type' => 'php'));
 }
开发者ID:Zyqsempai,项目名称:amanet,代码行数:15,代码来源:localization.php

示例14: _initCache

 /**
  * Set caching
  *
  * @return void
  */
 public function _initCache()
 {
     if (!Zend_Registry::isRegistered('cachemanager')) {
         return false;
     }
     $cache = HCMS_Cache::getInstance()->getCoreCache();
     //set cache for table metadata
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     //set cache for locale
     Zend_Locale::setCache($cache);
     //set cache for translate
     Zend_Translate::setCache($cache);
     //plugin loader cache
     $classFileIncCache = APPLICATION_PATH . '/../cache/file/pluginLoaderCache.php';
     if (file_exists($classFileIncCache)) {
         include_once $classFileIncCache;
     }
     Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
 }
开发者ID:bokultis,项目名称:kardiomedika,代码行数:24,代码来源:Bootstrap.php

示例15: _setCache

 /**
  * Sets the translation cache
  *
  * @return void
  */
 protected function _setCache()
 {
     $options = $this->getOptions();
     // Disable cache? If not defined, cache will be active
     if (isset($options['cache']['active']) && !$options['cache']['active']) {
         // Explicitly remove cache, in case it was set before
         Zend_Translate::removeCache();
         return;
     }
     // Get the cache using the config settings as input
     $this->_bootstrap->bootstrap('CacheManager');
     $manager = $this->_bootstrap->getResource('CacheManager');
     $cache = $manager->getCache('translate');
     // Write caching errors to log file (if activated in the config)
     $this->_bootstrap->bootstrap('Log');
     $logger = $this->_bootstrap->getResource('Log');
     $cache->setOption('logger', $logger);
     Zend_Translate::setCache($cache);
 }
开发者ID:nstapelbroek,项目名称:Glitch_Lib,代码行数:24,代码来源:Translate.php


注:本文中的Zend_Translate::setCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。