当前位置: 首页>>代码示例>>PHP>>正文


PHP Locales::isValidLocale方法代码示例

本文整理汇总了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;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:42,代码来源:summaryaction.class.php


注:本文中的Locales::isValidLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。