Beispiel #1
0
 protected function _initLanguage()
 {
     $available_languages = Core_Model_Language::getLanguageCodes();
     $current_language = in_array($this->_request->getLanguageCode(), $available_languages) ? $this->_request->getLanguageCode() : '';
     $language_session = Core_Model_Language::getSession();
     $language = '';
     if ($language_session) {
         $language = $language_session->current_language;
     }
     if (!empty($current_language)) {
         Core_Model_Language::setCurrentLanguage($current_language);
     } else {
         if (!empty($language)) {
             //            $this->_request->setLanguageCode($language);
         } else {
             if ($accepted_languages = Zend_Locale::getBrowser()) {
                 $accepted_languages = array_keys($accepted_languages);
                 //            $accepted_languages = preg_split('/(,)|(;)|(-)|(=)/', $accepted_languages);
                 foreach ($accepted_languages as $lang) {
                     if (in_array($lang, $available_languages)) {
                         $current_language = $lang;
                         break;
                     }
                 }
                 if (!$current_language) {
                     $current_language = Core_Model_Language::getDefaultLanguage();
                 }
                 Core_Model_Language::setCurrentLanguage($current_language);
             }
         }
     }
 }
Beispiel #2
0
 protected function _initLanguage()
 {
     $available_languages = Core_Model_Language::getLanguageCodes();
     $current_language = in_array($this->getRequest()->getLanguageCode(), $available_languages) ? $this->getRequest()->getLanguageCode() : "";
     $language_session = Core_Model_Language::getSession();
     $language = '';
     if (!$this->getRequest()->isApplication()) {
         if ($language_session->current_language) {
             $language = $language_session->current_language;
         } else {
             if (!$this->getRequest()->isInstalling()) {
                 $current_language = System_Model_Config::getValueFor("system_default_language");
             }
         }
     } else {
         $language = $language_session->current_language;
     }
     if (!empty($current_language)) {
         Core_Model_Language::setCurrentLanguage($current_language);
     } else {
         if (!empty($language)) {
         } else {
             if ($accepted_languages = Zend_Locale::getBrowser()) {
                 $accepted_languages = array_keys($accepted_languages);
                 foreach ($accepted_languages as $lang) {
                     if (in_array($lang, $available_languages)) {
                         $current_language = $lang;
                         break;
                     }
                 }
                 if (!$current_language) {
                     $current_language = Core_Model_Language::getDefaultLanguage();
                 }
                 Core_Model_Language::setCurrentLanguage($current_language);
             } else {
                 Core_Model_Language::setCurrentLanguage(Core_Model_Language::getDefaultLanguage());
             }
         }
     }
 }