Exemple #1
0
 public function init()
 {
     if (null === $this->_locale) {
         $sessionLocale = new Zend_Session_Namespace('locale');
         //Zend_Session::destroy();
         //var_dump($session->localename);
         //Zend_Debug::dump($_SESSION);exit;
         //Zend_Debug::dump(Zend_Session::getOptions());exit;
         if (isset($sessionLocale->localename)) {
             $this->_locale = new Zend_Locale($sessionLocale->localename);
         } else {
             $options = $this->getOptions();
             if (!isset($options['default'])) {
                 $this->_locale = new Zend_Locale();
             } elseif (!isset($options['force']) || (bool) $options['force'] == false) {
                 // Don't force any locale, just go for auto detection
                 Zend_Locale::setDefault($options['default']);
                 $this->_locale = new Zend_Locale();
             } else {
                 //强制区域为...
                 $this->_locale = new Zend_Locale($options['default']);
             }
             $sessionLocale->localename = $this->_locale->getLanguage() . '_' . $this->_locale->getRegion();
         }
         $key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
         Zend_Registry::set($key, $this->_locale);
         Zend_Registry::set('sessionLocale', $sessionLocale);
     }
     return $this->_locale;
 }
 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);
     }
 }
Exemple #3
0
 /**
  * Setup environment
  */
 public function setUp()
 {
     date_default_timezone_set('America/Chicago');
     Zend_Locale::setDefault('en_US');
     Zend_Amf_Parse_TypeLoader::resetMap();
     $this->_response = new Zend_Amf_Response();
 }
Exemple #4
0
 /**
  * Setup environment
  */
 public function setUp()
 {
     date_default_timezone_set("America/Chicago");
     Zend_Locale::setDefault('en');
     Zend_Amf_Parse_TypeLoader::resetMap();
     $this->_request = new Zend_Amf_Request();
 }
Exemple #5
0
 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) {
         }
     }
 }
Exemple #6
0
 /**
  * @param \HumusMvc\MvcEvent $e
  * @return void
  */
 public function __invoke(MvcEvent $e)
 {
     $serviceManager = $e->getApplication()->getServiceManager();
     $config = $serviceManager->get('Config');
     if (!isset($config['locale'])) {
         // no locale config found, return
         return;
     }
     // set cache in locale to speed up application
     if ($serviceManager->has('CacheManager')) {
         $cacheManager = $serviceManager->get('CacheManager');
         Locale::setCache($cacheManager->getCache('default'));
     }
     $options = $config['locale'];
     if (!isset($options['default'])) {
         $locale = new Locale();
     } elseif (!isset($options['force']) || (bool) $options['force'] == false) {
         // Don't force any locale, just go for auto detection
         Locale::setDefault($options['default']);
         $locale = new Locale();
     } else {
         $locale = new Locale($options['default']);
     }
     $key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
     Registry::set($key, $locale);
 }
Exemple #7
0
 protected function _initLanguage()
 {
     $locale = new Zend_Locale('de_AT');
     $translator = new Zend_Translate('array', APPLICATION_PATH . '/../resources/languages', 'de', array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     Zend_Locale::setDefault($locale);
 }
Exemple #8
0
 protected function startLocale()
 {
     require_once "Zend/Translate.php";
     // silenciando strict até arrumar zend_locale
     date_default_timezone_set("America/Sao_Paulo");
     $i18n = new Zend_Translate('gettext', $this->config->system->path->base . '/lang/pt_BR.mo', 'pt_BR');
     Zend_Registry::set('i18n', $i18n);
     $translation_files = $this->config->system->path->base . "/lang/";
     foreach (scandir($translation_files) as $filename) {
         // Todos os arquivos .php devem ser classes de descrição de modulos
         if (preg_match("/.*\\.mo\$/", $filename)) {
             $translation_id = basename($filename, '.mo');
             if ($translation_id != "pt_BR") {
                 $i18n->addTranslation($translation_files . "/{$filename}", $translation_id);
             }
         }
     }
     require_once "Zend/Locale.php";
     if (Zend_Locale::isLocale($this->config->system->locale)) {
         $locale = $this->config->system->locale;
     } else {
         $locale = "pt_BR";
     }
     Zend_Registry::set('Zend_Locale', new Zend_Locale($locale));
     Zend_Locale::setDefault($locale);
     Zend_Locale_Format::setOptions(array("locale" => $locale));
     $i18n->setLocale($locale);
     Zend_Registry::set("Zend_Translate", $i18n);
     $zend_validate_translator = new Zend_Translate_Adapter_Array($this->config->system->path->base . "/lang/Zend_Validate/{$locale}/Zend_Validate.php", $locale);
     Zend_Validate_Abstract::setDefaultTranslator($zend_validate_translator);
 }
Exemple #9
0
    /**
     * Retrieve locale object
     *
     * @return Zend_Locale
     */
    public function getLocale()
    {
        if (null === $this->_locale) {
            $options = $this->getOptions();

            if (!isset($options['default'])) {
                $this->_locale = new Zend_Locale();
            } elseif(!isset($options['force']) ||
                     (bool) $options['force'] == false)
            {
                // Don't force any locale, just go for auto detection
                Zend_Locale::setDefault($options['default']);
                $this->_locale = new Zend_Locale();
            } else {
                $this->_locale = new Zend_Locale($options['default']);
            }

            $key = (isset($options['registry_key']) && !is_numeric($options['registry_key']))
                ? $options['registry_key']
                : self::DEFAULT_REGISTRY_KEY;
            Zend_Registry::set($key, $this->_locale);
        }

        return $this->_locale;
    }
Exemple #10
0
 /**
  * Detect the locale
  *
  * @param Zend_Controller_Request_Abstract $request
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $language = $request->getParam('language_code');
     $locale = new Zend_Locale($language);
     Zend_Locale::setDefault($language);
     Zend_Registry::set('Zend_Locale', $locale);
 }
Exemple #11
0
 protected function _initDate()
 {
     $config = $this->getOption('configuration');
     date_default_timezone_set($config['date']['timezone']);
     setlocale(LC_ALL, $config['date']['locale']);
     \Zend_Locale::setDefault($config['date']['locale']);
     $date = new \Zend_Date();
     return $date;
 }
Exemple #12
0
 public function getLocaleInstance()
 {
     if ($this->_locale === null) {
         require_once 'Zend/Locale.php';
         Zend_Locale::setDefault(self::LANGUAGE_EN);
         $this->_locale = new Zend_Locale();
     }
     return $this->_locale;
 }
Exemple #13
0
 /**
  * Bootstrap the locale
  * 
  * @return void
  */
 protected function _initLocale()
 {
     date_default_timezone_set('America/Sao_Paulo');
     $locale = new Zend_Locale('pt_BR');
     Zend_Registry::set('Zend_Locale', $locale);
     Zend_Locale::setDefault($locale);
     Zend_Controller_Front::getInstance()->getRouter()->setGlobalParam('language', strtolower($locale->getRegion()));
     $translate = new Zend_Translate(array('adapter' => 'csv', 'content' => APPLICATION_PATH . '/languages/default/' . $locale->toString() . '.csv'));
     Zend_Registry::set('Zend_Translate', $translate);
 }
Exemple #14
0
 protected function _initTranslator()
 {
     $session = Zend_Registry::get('session');
     Zend_Locale::setDefault('en');
     $locale = isset($session->locale) ? $session->locale : new Zend_Locale(Zend_Locale::ZFDEFAULT);
     Zend_Registry::set('Zend_Locale', $locale);
     $session->locale = $locale;
     $translator = new Zend_Translate(array('adapter' => 'array', 'content' => INSTALL_PATH . DIRECTORY_SEPARATOR . 'system/languages/', 'scan' => Zend_Translate::LOCALE_FILENAME, 'locale' => $locale->getLanguage(), 'ignore' => array('.'), 'route' => array('fr' => 'en', 'it' => 'en', 'de' => 'en')));
     Zend_Form::setDefaultTranslator($translator);
     Zend_Registry::set('Zend_Translate', $translator);
     Zend_Registry::set('session', $session);
 }
Exemple #15
0
 protected function _initLocale()
 {
     Zend_Loader::loadClass('Zend_Locale');
     Zend_Locale::setDefault('fr');
     $session = new Zend_Session_Namespace();
     $session->locale = !empty($session->locale) ? $session->locale : DEFAULT_LOCALE;
     $translator = new Zend_Translate(array('adapter' => 'array', 'content' => APPLICATION_PATH . '/languages/' . $session->locale . '.php', 'locale' => $session->locale));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     Zend_Form::setDefaultTranslator($translator);
     Zend_Validate::setDefaultTranslator($translator);
     Zend_Registry::set("Zend_Translate", $translator);
 }
 /**
  * Initialize the locale resource.
  */
 protected function _initLocale()
 {
     $session = $this->getResource("session");
     Zend_Locale::setDefault('en_US');
     if (!isset($session->locale)) {
         $session->locale = 'en_US';
         $session->localeChosen = false;
     }
     $locale = new Zend_Locale($session->locale);
     Zend_Registry::set('Zend_Locale', $locale);
     return $locale;
 }
Exemple #17
0
 /**
  * Retrieve locale object
  *
  * @return Zend_Locale
  */
 public function getLocale()
 {
     if (null === $this->_locale) {
         $options = $this->getOptions();
         if (isset($options['default'])) {
             Zend_Locale::setDefault($options['default']);
         }
         $this->_locale = new Zend_Locale();
         $key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
         Zend_Registry::set($key, $this->_locale);
     }
     return $this->_locale;
 }
Exemple #18
0
/**
 * configuring Filez
 */
function before()
{
    if (fz_config_get('app', 'use_url_rewriting')) {
        option('base_uri', option('base_path'));
    }
    // error handling
    if (fz_config_get('app', 'debug', false)) {
        ini_set('display_errors', true);
        option('debug', true);
        option('env', ENV_DEVELOPMENT);
    } else {
        ini_set('display_errors', false);
        option('debug', false);
    }
    // I18N
    Zend_Locale::setDefault(fz_config_get('app', 'default_locale', 'fr'));
    $currentLocale = new Zend_Locale('auto');
    $translate = new Zend_Translate('gettext', option('root_dir') . DIRECTORY_SEPARATOR . 'i18n', $currentLocale, array('scan' => Zend_Translate::LOCALE_DIRECTORY));
    option('translate', $translate);
    option('locale', $currentLocale);
    // Execute DB configuration only if Filez is configured
    if (!option('installing')) {
        // check log dir
        if (!is_writable(fz_config_get('app', 'log_dir'))) {
            trigger_error('Log dir is not writeable "' . fz_config_get('app', 'log_dir') . '"', E_USER_WARNING);
        }
        // check upload dir
        if (!is_writable(fz_config_get('app', 'upload_dir'))) {
            trigger_error('Upload dir is not writeable "' . fz_config_get('app', 'upload_dir') . '"', E_USER_ERROR);
        }
        // Database configuration
        try {
            $db = new PDO(fz_config_get('db', 'dsn'), fz_config_get('db', 'user'), fz_config_get('db', 'password'));
            $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $db->exec('SET NAMES \'utf8\'');
            option('db_conn', $db);
        } catch (Exception $e) {
            halt(SERVER_ERROR, 'Can\'t connect to the database');
        }
        // Initialise and save the user factory
        $factoryClass = fz_config_get('app', 'user_factory_class');
        $userFactory = new $factoryClass();
        $userFactory->setOptions(fz_config_get('user_factory_options', null, array()));
        option('userFactory', $userFactory);
    }
}
Exemple #19
0
 /**
  * Retrieves the locale object
  *
  * @return Zend_Locale
  * @throws Glitch_Application_Resource_Exception
  */
 public function getLocale()
 {
     if (null === $this->_locale) {
         $options = $this->getOptions();
         // Force these options to be set - don't rely on the defaults!
         if (!isset($options['default'])) {
             throw new Glitch_Application_Resource_Exception('Locale option "default" not set');
         }
         // First init cache, then create the locale
         $this->_setCache();
         $this->_locale = new Zend_Locale($options['default']);
         Zend_Locale::setDefault($this->_locale);
         // Allow application-wide access; e.g. Zend_Date uses this
         Glitch_Registry::setLocale($this->_locale);
         // Force formatter to use the above registered default locale
         Zend_Locale_Format::setOptions(array('locale' => null));
     }
     return $this->_locale;
 }
Exemple #20
0
 /**
  * This is where we set up the locale and set the translation adapters
  * @deprecate this could be set in the site.ini using resoruces
  * @return void
  */
 protected function _initLocale()
 {
     //this is the locale
     try {
         $locale = new Zend_Locale(Zend_Locale::BROWSER);
     } catch (Zend_Locale_Exception $e) {
         $locale = new Zend_Locale('en_US');
     }
     Zend_Locale::setDefault($locale);
     // here we define the translator
     $translatePath = APPLICATION_PATH . '/languages/translate.xml';
     $options = array('log' => Zend_Registry::get('logger'), 'disableNotices' => false, 'logMessage' => "Untranslated message within '%locale%': %message% : %word%");
     $translate = new Zend_Translate('tmx', $translatePath, $locale, $options);
     // hwere we add the translator to the registry
     Zend_Registry::set('translate', $translate);
     // here we set all forms attached to the translator
     // this will translate everything on the form
     Zend_Form::setDefaultTranslator($translate);
 }
Exemple #21
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $lang = $this->getRequest()->getParam('lang');
     if (!in_array($lang, array_keys($this->_languages))) {
         $lang = 'en';
     }
     $this->_persistUserPreferedLanguage($lang);
     $localeString = $this->_languages[$lang];
     $locale = new Zend_Locale($localeString);
     Zend_Locale::setDefault($localeString);
     $file = $this->_dir . '/' . $localeString . '.mo';
     if (!file_exists($file)) {
         throw new Exception('Missing $translationStrings in language file ' . $file);
     }
     $translate = new Zend_Translate('gettext', $file, $localeString);
     Zend_Registry::set('lang', $lang);
     Zend_Registry::set('localeString', $localeString);
     Zend_Registry::set('Zend_Locale', $locale);
     Zend_Registry::set('Zend_Translate', $translate);
 }
Exemple #22
0
 /**
  * test setDefault
  * expected true
  */
 public function testsetDefault()
 {
     try {
         Zend_Locale::setDefault('auto');
         $this->fail();
     } catch (Zend_Locale_Exception $e) {
         $this->assertContains("full qualified locale", $e->getMessage());
     }
     try {
         Zend_Locale::setDefault('de_XX');
         $locale = new Zend_Locale();
         $this->assertTrue($locale instanceof Zend_Locale);
         // should defer to 'de' or any other standard locale
     } catch (Zend_Locale_Exception $e) {
         $this->fail();
         // de_XX should automatically degrade to 'de'
     }
     try {
         Zend_Locale::setDefault('xy_ZZ');
         $this->fail();
     } catch (Zend_Locale_Exception $e) {
         $this->assertContains("Unknown locale", $e->getMessage());
     }
 }
Exemple #23
0
 public function _initLocale()
 {
     Zend_Locale::setDefault('en_US');
     Zend_Registry::set('Zend_Locale', new Zend_Locale());
 }
Exemple #24
0
 protected function _initLocale()
 {
     Zend_Locale::setDefault('en-US');
 }
 */
$dlConfig['params']['apiToken'] = (string) 'YOUR_API_TOKEN_HERE';
$dlConfig['params']['secretKey'] = (string) 'YOUR_SECRET_KEY_HERE';
$dlConfig['params']['buyerId'] = (string) 'YOUR_OFFICEID_HERE';
$dlConfig['params']['apiVersion'] = (string) '9';
$dlConfig['params']['usePersistentConnections'] = (bool) true;
//$dlConfig['params']['baseUri']                       = (string) 'https://api.sandbox.ticketevolution.com'; // Sandbox
$dlConfig['params']['baseUri'] = (string) 'https://api.ticketevolution.com';
// Production
/**
 * Database setup
 * Make sure you have created the database using the script
 * provided in scripts/create_tables.mysql
 * as well as applying any updates in chronological order
 *
 */
$dlConfig['database']['adapter'] = 'Mysqli';
$dlConfig['database']['params']['host'] = 'YOUR_MYSQL_HOST';
$dlConfig['database']['params']['dbname'] = 'YOUR_DATABASE_NAME';
$dlConfig['database']['params']['username'] = '******';
$dlConfig['database']['params']['password'] = '******';
/**
 * LOCALE SETTINGS
 * If this isn't set in your php.ini set it here.
 * @link http://www.php.net/manual/en/timezones.america.php
 */
if (ini_get('date.timezone') === '') {
    date_default_timezone_set('UTC');
}
\Zend_Locale::setDefault('en_US');
Exemple #26
0
 /**
  * Find out locale from the request, settings or session
  * if language choice enabled, try the following:
  *      - REQUEST parameter "lang"
  *      - SESSION parameter "lang"
  *      - Am_App::getUser->lang
  *      - default in App
  *      - en_US
  * else use latter 2
  */
 static function initLocale(Am_Di $di)
 {
     if (defined('AM_ADMIN') && AM_ADMIN) {
         Zend_Locale::setDefault('en_US');
     } else {
         $possibleLang = array();
         if ($di->config->get('lang.display_choice')) {
             $auth = $di->auth;
             $user = $auth->getUserId() ? $auth->getUser() : null;
             if (!empty($_REQUEST['_lang'])) {
                 $possibleLang[] = filterId($_REQUEST['_lang']);
             } elseif (!empty($di->session->lang)) {
                 $possibleLang[] = $di->session->lang;
             } elseif ($user && $user->lang) {
                 $possibleLang[] = $user->lang;
             }
             $br = Zend_Locale::getBrowser();
             arsort($br);
             $possibleLang = array_merge($possibleLang, array_keys($br));
         }
         $possibleLang[] = $di->config->get('lang.default', 'en_US');
         $possibleLang[] = 'en_US';
         // last but not least
         // now choose the best candidate
         $enabledLangs = $di->config->get('lang.enabled', array());
         $checked = array();
         foreach ($possibleLang as $lc) {
             list($lang) = explode('_', $lc, 2);
             if (!in_array($lc, $enabledLangs) && !in_array($lang, $enabledLangs)) {
                 continue;
             }
             if ($lc == $lang) {
                 // we have not got entire locale,guess it
                 if ($lc == 'en') {
                     $lc = 'en_US';
                 } elseif ($lc == 'sv') {
                     $lc = 'sv_SE';
                 } elseif ($lc == 'et') {
                     $lc = 'et_EE';
                 } elseif ($lc == 'vi') {
                     $lc = 'vi_VN';
                 } else {
                     $lc = Zend_Locale::getLocaleToTerritory($lang);
                 }
                 if (!$lc && $lang == 'ko') {
                     $lc = 'ko_KR';
                 }
                 if (!$lc && $lang == 'ja') {
                     $lc = 'ja_JP';
                 }
                 if (!$lc && $lang == 'nb') {
                     $lc = 'nb_NO';
                 }
                 if (!$lc && $lang == 'zh') {
                     $lc = 'zh_Hans';
                 }
                 if (!$lc && $lang == 'el') {
                     $lc = 'el_GR';
                 }
                 if (!$lc && $lang == 'he') {
                     $lc = 'he_IL';
                 }
                 if (!$lc && $lang == 'da') {
                     $lc = 'da_DK';
                 }
                 if (!$lc && $lang == 'cs') {
                     $lc = 'cs_CZ';
                 }
                 if (!$lc && $lang == 'sq') {
                     $lc = 'sq_AL';
                 }
                 if (!$lc) {
                     continue;
                 }
             }
             if (isset($checked[$lc])) {
                 continue;
             }
             $checked[$lc] = true;
             // check if locale file is exists
             $lc = preg_replace('/[^A-Za-z0-9_]/', '', $lc);
             if (!Zend_Locale::isLocale($lc)) {
                 continue;
             }
             Zend_Locale::setDefault($lc);
             // then update user if it was request
             // and set to session
             break;
         }
         if ($di->config->get('lang.display_choice') && !empty($_REQUEST['_lang'])) {
             if (($_REQUEST['_lang'] == $lang || $_REQUEST['_lang'] == $lc) && $user && $user->lang != $lang) {
                 $user->updateQuick('lang', $lc);
             }
             // set to session
             $di->session->lang = $lc;
         }
     }
     Zend_Registry::set('Zend_Locale', new Zend_Locale());
     $amLocale = new Am_Locale();
     Zend_Registry::set('Am_Locale', $amLocale);
     $di->locale = $amLocale;
     Zend_Locale_Format::setOptions(array('date_format' => $amLocale->getDateFormat()));
 }
 protected function _initSession()
 {
     Zend_Locale::setDefault('en_US');
     Zend_Session::start();
 }
Exemple #28
0
 /**
  * Localization (for date and formats)
  */
 public function setLocalization()
 {
     $locale = new Zend_Locale($this->config->general->locale);
     Zend_Locale::setDefault($this->config->general->locale);
     $this->registry->set('locale', $locale);
 }
Exemple #29
0
 /**
  * Set current locale in Zend_Locale::setDefault(), Zend_Registry and
  * Adapter.
  *
  * @param Zend_Locale|string $locale
  */
 public static function setLocale($locale = null)
 {
     if (!$locale) {
         $locale = self::findLocale();
     }
     if (is_string($locale)) {
         try {
             $locale = new Zend_Locale($locale);
             if ($locale->__toString() == 'root') {
                 $locale = self::getDefaultLocale();
             }
         } catch (Exception $e) {
             $locale = new Zend_Locale();
         }
     }
     try {
         Zend_Locale::setDefault($locale);
     } catch (Exception $e) {
         Zend_Locale::setDefault(self::getDefaultLocale());
     }
     Zend_Registry::set('Zend_Locale', $locale);
     $adapter = self::getAdapter();
     $adapter->locale = (string) $locale;
     self::$locale = $locale;
 }
Exemple #30
0
 public function _initLocale()
 {
     Zend_Locale::setDefault('en');
 }