当前位置: 首页>>代码示例>>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;未经允许,请勿转载。