當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PMF_Init::getUserAgentLanguage方法代碼示例

本文整理匯總了PHP中PMF_Init::getUserAgentLanguage方法的典型用法代碼示例。如果您正苦於以下問題:PHP PMF_Init::getUserAgentLanguage方法的具體用法?PHP PMF_Init::getUserAgentLanguage怎麽用?PHP PMF_Init::getUserAgentLanguage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PMF_Init的用法示例。


在下文中一共展示了PMF_Init::getUserAgentLanguage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setLanguage

 /**
  * setLanguage()
  *
  * Sets the current language for phpMyFAQ user session
  *
  * @param    bool    $config_detection
  * @param    string  $config_language
  * @return   string  $language
  * @access   public
  * @author   Thorsten Rinne <rinne@mayflower.de>
  * @author   Matteo scaramuccia <matteo@scaramuccia.com>
  */
 function setLanguage($config_detection, $config_language)
 {
     $_lang = array();
     PMF_Init::getUserAgentLanguage();
     // Get language from: _POST, _GET, _COOKIE, phpMyFAQ configuration and
     //                    the automatic language detection
     if (isset($_POST['language']) && PMF_Init::isASupportedLanguage($_POST['language'])) {
         $_lang['post'] = $_POST['language'];
     }
     // Get the user language
     if (isset($_GET['lang']) && PMF_Init::isASupportedLanguage($_GET['lang'])) {
         $_lang['get'] = $_GET['lang'];
     }
     // Get the faq record language
     if (isset($_GET['artlang']) && PMF_Init::isASupportedLanguage($_GET['artlang'])) {
         $_lang['get'] = $_GET['artlang'];
     }
     // Get the language from the cookie
     if (isset($_COOKIE['pmf_lang']) && PMF_Init::isASupportedLanguage($_COOKIE['pmf_lang'])) {
         $_lang['cookie'] = $_COOKIE['pmf_lang'];
     }
     // Get the language from the config
     if (isset($config_language)) {
         $confLangCode = str_replace(array("language_", ".php"), "", $config_language);
         if (PMF_Init::isASupportedLanguage($confLangCode)) {
             $_lang['config'] = $confLangCode;
         }
     }
     // Detect the browser's language
     if (true === $config_detection && PMF_Init::isASupportedLanguage($this->acceptedLanguage)) {
         $_lang['detection'] = $this->acceptedLanguage;
     }
     // Select the language
     if (isset($_lang['post'])) {
         $this->language = $_lang['post'];
         unset($_lang);
         setcookie('pmf_lang', $this->language, time() + 3600);
     } elseif (isset($_lang['get'])) {
         $this->language = $_lang['get'];
     } elseif (isset($_lang['cookie'])) {
         $this->language = $_lang['cookie'];
         unset($_lang);
     } elseif (isset($_lang['config'])) {
         $this->language = $_lang['config'];
         unset($_lang);
         setcookie('pmf_lang', $this->language, time() + 3600);
     } elseif (isset($_lang['detection'])) {
         $this->language = $_lang['detection'];
         unset($_lang);
         setcookie('pmf_lang', $this->language, time() + 3600);
     } else {
         $this->language = 'en';
         // just a fallback
     }
     return $this->language;
 }
開發者ID:juliogallardo1326,項目名稱:proc,代碼行數:68,代碼來源:init.php


注:本文中的PMF_Init::getUserAgentLanguage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。