當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。