本文整理匯總了PHP中Locales::isValidLocale方法的典型用法代碼示例。如果您正苦於以下問題:PHP Locales::isValidLocale方法的具體用法?PHP Locales::isValidLocale怎麽用?PHP Locales::isValidLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Locales
的用法示例。
在下文中一共展示了Locales::isValidLocale方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: elseif
/**
* 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;
}