public function init() { $controller = $this->getActionController(); if (!($requestedLocale = $controller->getRequest()->getParam('language', false))) { $local = new Zend_Locale(); $requestedLocale = $local->getLanguage(); } if (is_array($requestedLocale)) { $requestedLocale = current($requestedLocale); } $requestedLocale = strtolower($requestedLocale); try { Centurion_Db::getSingleton('translation/language')->get(array('locale' => $requestedLocale)); } catch (Centurion_Db_Table_Row_Exception_DoesNotExist $e) { $requestedLocale = Translation_Traits_Common::getDefaultLanguage(); $requestedLocale = $requestedLocale->locale; } Zend_Registry::get('Zend_Translate')->setLocale($requestedLocale); Zend_Locale::setDefault($requestedLocale); Zend_Registry::set('Zend_Locale', $requestedLocale); $options = Centurion_Db_Table_Abstract::getDefaultFrontendOptions(); if (!isset($options['cache_id_prefix'])) { $options['cache_id_prefix'] = ''; } $options['cache_id_prefix'] = $requestedLocale . '_' . $options['cache_id_prefix']; Centurion_Db_Table_Abstract::setDefaultFrontendOptions($options); //TODO: fix this when in test unit environment if (!APPLICATION_ENV === 'testing') { $this->getActionController()->getFrontController()->getParam('bootstrap')->getResource('cachemanager')->addIdPrefix($requestedLocale . '_'); } if (Centurion_Config_Manager::get('translation.global_param')) { $this->getFrontController()->getRouter()->setGlobalParam('language', $requestedLocale); } }
public function getCache($frontendOptions = null, $backendOptions = null) { if (null === $this->_cache) { if (null === $frontendOptions) { $frontendOptions = Centurion_Db_Table_Abstract::getDefaultFrontendOptions(); } if (null === $backendOptions) { $backendOptions = Centurion_Db_Table_Abstract::getDefaultBackendOptions(); } $frontendOptions['cache_id_prefix'] = get_class($this) . '_' . md5(serialize($this->pk)) . '_'; $this->_cache = new Centurion_Db_Cache($this, $frontendOptions, $backendOptions); } return $this->_cache; }