Skip to content

Commit

Permalink
Merge pull request #969 from syudal/master
Browse files Browse the repository at this point in the history
Update init.php
  • Loading branch information
zhblue authored Sep 27, 2023
2 parents feaf046 + 75d0ce1 commit 52b4c7b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions trunk/web/include/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@
$OJ_LANG=$_COOKIE['lang'];
} else if (isset($_GET['lang']) && in_array($_GET['lang'], array("cn", "ug", "en", 'fa', 'ko', 'th'))) {
$OJ_LANG=$_GET['lang'];
} else if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && strstr($_SERVER['HTTP_ACCEPT_LANGUAGE'], "zh-CN")) {
$OJ_LANG="cn";
} else if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$userLanguages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach ($userLanguages as $userLang) {
$langParts = explode(';', $userLang);
$lang = strtolower(substr($langParts[0], 0, 2));
if (in_array($lang, array("cn", "ug", "en", 'fa', 'ko', 'th'))) {
$OJ_LANG = $lang;
break;
}
}
}
require(dirname(__FILE__)."/../lang/$OJ_LANG.php");

Expand Down

0 comments on commit 52b4c7b

Please sign in to comment.