如您所知,atutor首先检查用户的浏览器以检测语言,如果找不到,则使用管理员设置的默认语言。我搜索并找到了代码,你知道我怎么能改变它以便atutor直接使用默认语言而不是先检查用户的吗?
/**
* Tries to detect the user's current language preference/setting from (in order):
* _GET, _POST, _SESSION, HTTP_ACCEPT_LANGUAGE, HTTP_USER_AGENT. If no match can be made
* then it tries to detect a default setting (defined in config.inc.php) or a fallback
* setting, false if all else fails.
* @access public
* @return boolean|Language Returns a Language Object matching the user's current session.
* Returns FALSE if a valid Language Object cannot be found
* to match the request
* @see getLanguage()
*/
function getMyLanguage() {
global $addslashes, $db;
if (isset($_GET) && !empty($_GET['lang']) && isset($this->availableLanguages[$_GET['lang']])) {
$language = $this->getLanguage($_GET['lang']);
if ($language) {
return $language;
}
}
if (isset($_POST) && !empty($_POST['lang']) && isset($this->availableLanguages[$_POST['lang']])) {
$language = $this->getLanguage($_POST['lang']);
if ($language) {
return $language;
}
}
if (isset($_SESSION) && isset($_SESSION['lang']) && !empty($_SESSION['lang']) && isset($this->availableLanguages[$_SESSION['lang']])) {
$language = $this->getLanguage($_SESSION['lang']);
if ($language) {
return $language;
}
}
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
// Language is not defined yet :
// try to find out user's language by checking its HTTP_ACCEPT_LANGUAGE
$accepted = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$acceptedCnt = count($accepted);
reset($accepted);
for ($i = 0; $i < $acceptedCnt; $i++) {
foreach ($this->availableLanguages as $codes) {
foreach ($codes as $language) {
if ($language->isMatchHttpAcceptLanguage($accepted[$i])) {
return $language;
}
}
}
}
}
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
// Language is not defined yet :
// try to find out user's language by checking its HTTP_USER_AGENT
foreach ($this->availableLanguages as $codes) {
foreach ($codes as $language) {
if ($language->isMatchHttpUserAgent($_SERVER['HTTP_USER_AGENT'])) {
return $language;
}
}
}
}
// Didn't catch any valid lang : we use the default settings
if (isset($this->availableLanguages[DEFAULT_LANGUAGE])) {
$language = $this->getLanguage(DEFAULT_LANGUAGE, DEFAULT_CHARSET);
if ($language) {
return $language;
}
}
// fail safe
if (isset($this->availableLanguages[$this->default_lang])) {
$language = $this->getLanguage($this->default_lang, $this->default_charset);
if ($language) {
return $language;
}
}
// else pick one at random:
reset($this->availableLanguages);
$unknown_language = current($this->availableLanguages);
if (!$unknown_language) {
return FALSE;
}
return current($unknown_language);
}
function getAvailableLanguages() {
return $this->availableLanguages;
}
答案 0 :(得分:0)
你应该只需要注释掉这个块:
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
// Language is not defined yet :
// try to find out user's language by checking its HTTP_ACCEPT_LANGUAGE
$accepted = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$acceptedCnt = count($accepted);
reset($accepted);
for ($i = 0; $i < $acceptedCnt; $i++) {
foreach ($this->availableLanguages as $codes) {
foreach ($codes as $language) {
if ($language->isMatchHttpAcceptLanguage($accepted[$i])) {
return $language;
}
}
}
}
}