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


PHP CLocale::getCanonicalID方法代码示例

本文整理汇总了PHP中CLocale::getCanonicalID方法的典型用法代码示例。如果您正苦于以下问题:PHP CLocale::getCanonicalID方法的具体用法?PHP CLocale::getCanonicalID怎么用?PHP CLocale::getCanonicalID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLocale的用法示例。


在下文中一共展示了CLocale::getCanonicalID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPreferredAvailableLanguage

 public function getPreferredAvailableLanguage()
 {
     $preferedLanguages = $this->getPreferredLanguages();
     $languages = array_keys(Yii::app()->params['availableLanguages']);
     foreach ($preferedLanguages as $preferredLanguage) {
         foreach ($languages as $language) {
             $preferredLanguage = CLocale::getCanonicalID($preferredLanguage);
             if ($language === $preferredLanguage) {
                 return $language;
             }
         }
     }
     return false;
 }
开发者ID:skapl,项目名称:design,代码行数:14,代码来源:HHttpRequest.php

示例2: getPreferredLanguage

 /**
  * Returns the user preferred language.
  * The returned language ID will be canonicalized using {@link CLocale::getCanonicalID}.
  * This method returns false if the user does not have language preference.
  * @return string the user preferred language.
  */
 public function getPreferredLanguage()
 {
     if ($this->_preferredLanguage === null) {
         if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && ($n = preg_match_all('/([\\w\\-_]+)\\s*(;\\s*q\\s*=\\s*(\\d*\\.\\d*))?/', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches)) > 0) {
             $languages = array();
             for ($i = 0; $i < $n; ++$i) {
                 $languages[$matches[1][$i]] = empty($matches[3][$i]) ? 1.0 : floatval($matches[3][$i]);
             }
             arsort($languages);
             foreach ($languages as $language => $pref) {
                 return $this->_preferredLanguage = CLocale::getCanonicalID($language);
             }
         }
         return $this->_preferredLanguage = false;
     }
     return $this->_preferredLanguage;
 }
开发者ID:jicheng17,项目名称:yiifamilyblog,代码行数:23,代码来源:CHttpRequest.php

示例3: getPreferredLanguage

 public function getPreferredLanguage()
 {
     $preferredLanguages = $this->getPreferredLanguages();
     return !empty($preferredLanguages) ? CLocale::getCanonicalID($preferredLanguages[0]) : false;
 }
开发者ID:smokeelow,项目名称:faicore,代码行数:5,代码来源:yiilite.php

示例4: setLanguage

 /**
  * @param string $language the language that the source messages are written in.
  */
 public function setLanguage($language)
 {
     $this->_language = CLocale::getCanonicalID($language);
 }
开发者ID:frogoscar,项目名称:mobcent-discuz,代码行数:7,代码来源:CMessageSource.php

示例5: getPreferredLanguage

 public function getPreferredLanguage($languages = array())
 {
     $preferredLanguages = $this->getPreferredLanguages();
     if (empty($languages)) {
         return !empty($preferredLanguages) ? CLocale::getCanonicalID($preferredLanguages[0]) : false;
     }
     foreach ($preferredLanguages as $preferredLanguage) {
         $preferredLanguage = CLocale::getCanonicalID($preferredLanguage);
         foreach ($languages as $language) {
             $language = CLocale::getCanonicalID($language);
             // en_us==en_us, en==en_us, en_us==en
             if ($language === $acceptedLanguage || strpos($acceptedLanguage, $language . '_') === 0 || strpos($language, $acceptedLanguage . '_') === 0) {
                 return $language;
             }
         }
     }
     return reset($languages);
 }
开发者ID:karikeb,项目名称:final2015,代码行数:18,代码来源:yiilite.php


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