-
Notifications
You must be signed in to change notification settings - Fork 67
/
language.php
66 lines (56 loc) · 1.4 KB
/
language.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/*!
* ATTENTION: THIS FREE LICENSE IS ONLY FOR PERSONAL NON-COMMERCIAL USER. FOR COMMERCIAL PURPOSES, PLEASE PURCHASE A COMMERCIAL LICENSE! *
* module: Centcount Analytics Free Language PHP Code *
* version: 1.00 Free *
* author: WM Jonssen *
* date: 03/12/2018 *
* copyright 2015-2018 WM Jonssen <[email protected]> - All rights reserved. *
* license: Dual licensed under the Free License and Commercial License. *
* https://www.centcount.com *
*/
$LAN = init_language();
function init_language() {
$lan = '';
$lanfile = '';
if (isset($_GET['lan'])) {
$lan = $_GET['lan'];
} else {
if (isset($_SESSION['lan'])) {
$lan = $_SESSION['lan'];
} else {
$lan = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : 'en-US';
}
}
$_SESSION['lan'] = $lan;
$country = strtoupper(substr($lan, 3, 5));
$lanuage = strtolower(substr($lan, 0, 2));
switch ($lanuage) {
default:
case 'en':
$lanfile = 'en-US.php';
break;
case 'zh':
switch ($country) {
default:
case 'CN':
case 'SG':
$lanfile = 'zh-CN.php';
break;
case 'TW':
case 'HK':
$lanfile = 'zh-TW.php';
break;
}
break;
case 'de':
$lanfile = 'de-DE.php';
break;
case 'ja':
$lanfile = 'ja-JP.php';
break;
}
require './language/lan-'.$lanfile;
return $lanfile;
}
?>