/** * Loads the current locale. It works so that it tries to fetch the parameter "lang" from the * request. If it's not available, then it will try to look for it in the session. If it is not * there either, it will try to guess the most prefered language according to what the User Agent * included in the HTTP_ACCEPT_LANGUAGE string sent with the request. If none matches available * languages we have to use the value of "default_locale" and display the default language. * * @private * @return Returns a reference to a Locale object */ function &_loadLocale() { $requestLocale =& $this->_request->getValue("lang"); $localeCode = ""; $serverVars =& HttpVars::getServer(); // check if there's something in the request... // if not, check the session or at least try to // guess the apropriate languege from the http_accept_lnaguage string if ($requestLocale) { // check if it's a valid one if (Locales::isValidLocale($requestLocale)) { $localeCode = $requestLocale; } } else { $sessionLocale =& SessionManager::getSessionValue("summaryLang"); if ($sessionLocale) { $localeCode = $sessionLocale; } elseif ($this->_config->getValue("use_http_accept_language_detection", HTTP_ACCEPT_LANGUAGE_DETECTION) == 1) { $localeCode =& $this->_matchHttpAcceptLanguages($serverVars['HTTP_ACCEPT_LANGUAGE']); } } // check if the locale code is correct // and as a valid resort, use the default one if the locale ist not valid or 'false' if ($localeCode === false || !Locales::isValidLocale($localeCode)) { $localeCode = $this->_config->getValue("default_locale"); } // now put whatever locale value back to the session SessionManager::setSessionValue("summaryLang", $localeCode); // load the correct locale $locale =& Locales::getLocale($localeCode); return $locale; }