-
Notifications
You must be signed in to change notification settings - Fork 9
/
chklang.php
executable file
·168 lines (151 loc) · 6.07 KB
/
chklang.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
/* $Id: chklang.php,v 1.4 2009/07/13 16:57:17 timschofield Exp $ */
/**
* phpMyAdmin Language Loading File - lolo@phpheaven.net 01may2001
*/
/**
* Define the path to the translations directory and get some variables
* from system arrays if 'register_globals' is set to 'off'
*/
$lang_path = 'language/';
/**
* All the suported languages have to be listed in the array below.
* 1. The key key must be the "official" ISO language code and, if required,
* the dialect code. It can also contains some informations about the
* charset (see the Russian case).
* These code are displayed at the starting page of phpMyAdmin.
* 2. The first of the values associated to the key is used in a regular
* expression to find some keywords corresponding to the language inside two
* environment variables.
* These values contains:
* - the "official" ISO language code and, if required, the dialect code
* also ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French
* dialects, 'zh[-_]tw' for Chinese traditional...);
* - the '|' character (it means 'OR');
* - the full language name.
* 3. The second values associated to the key is the name of the file to load
* without the 'inc.php' extension.
*
* Beware that the sorting order (first values associated to keys by
* alphabetical reverse order in the array) is important: 'zh-tw' (chinese
* traditional) must be detected before 'zh' (chinese simplified) for
* example.
*/
$available_languages = array(
'ar' => array('ar|Arabic', '28596'),
'bg' => array('bg|bulgarian', 'bulgarian-win1251'),
'bs' => array('bs|bosnian', 'bosnian-win1250'),
'ca' => array('ca|catalan', 'catala'),
'cs-iso' => array('cs|czech', 'czech-iso'),
'cs-win1250' => array('cs|czech', 'czech-win1250'),
'da' => array('da|danish', 'danish'),
'de' => array('de([-_][[:alpha:]]{2})?|german', 'german'),
'en' => array('en([-_][[:alpha:]]{2})?|english', 'english'),
'es' => array('es([-_][[:alpha:]]{2})?|spanish', 'spanish'),
'fa' => array('fa|Farsi', 'farsi'),
'fr' => array('fr([-_][[:alpha:]]{2})?|french', 'french'),
'id' => array('id|indonesian', 'indonesian'),
'it' => array('it|italian', 'italian'),
'ja' => array('ja|japanese', 'japanese'),
'ko' => array('ko|korean', 'korean'),
'nl' => array('nl([-_][[:alpha:]]{2})?|dutch', 'dutch'),
'no' => array('no|norwegian', 'norwegian'),
'pl' => array('pl|polish', 'polish'),
'pt-br' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese'),
'pt' => array('pt([-_][[:alpha:]]{2})?|portuguese', 'portuguese'),
'ru-koi8r' => array('ru|russian', 'russian-koi8'),
'ru-win1251' => array('ru|russian', 'russian-win1251'),
'se' => array('se|swedish', 'swedish'),
'sr' => array('sr|serbian', 'serbian-win1250'),
'th' => array('th|thai', 'thai'),
'zh-tw' => array('zh[-_]tw|chinese traditional', 'chinese_big5'),
'zh' => array('zh|chinese simplified', 'chinese_gb')
);
if (!defined('__PMA_LANG_DETECT__')) {
define('__PMA_LANG_DETECT__', 1);
/**
* Analyzes some PHP environment variables to find the most probable language
* that should be used
*
* @param string string to analyze
* @param integer type of the PHP environment variable which value is $str
*
* @global array the list of available translations
* @global string the retained translation keyword
*
* @access private
*/
function pmaLangDetect($str = '', $envType = '')
{
global $available_languages;
global $lang;
reset($available_languages);
while (list($key, $value) = each($available_languages)) {
// $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,
// 2 for the 'HTTP_USER_AGENT' one
if (($envType == 1 && eregi('^(' . $value[0] . ')(;q=[0-9]\\.[0-9])?$', $str))
|| ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $value[0] . ')(;|\]|\))', $str))) {
$lang = $key;
break;
}
}
} // end of the 'pmcLangDetect()' function
} // end if
$lang='en';
/**
* Get some global variables if 'register_globals' is set to 'off'
*/
// if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))
// $HTTP_ACCEPT_LANGUAGE = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
// if (!empty($_SERVER['HTTP_USER_AGENT']))
// $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
if (!isset($lang)) {
// if (isset($_GET) && !empty($_GET['lang'])) {
$lang = $_GET['lang'];
}
// if (isset($_POST) && !empty($_POST['lang'])) {
// $lang = $_POST['lang'];
// }
//}
/**
* Do the work!
*/
// Lang forced
if (!empty($cfgLang)) {
$lang = $cfgLang;
}
// If '$lang' is defined, ensure this is a valid translation
if (!empty($lang) && empty($available_languages[$lang])) {
$lang = '';
}
// Language is not defined yet :
// 1. try to findout users language by checking it's HTTP_ACCEPT_LANGUAGE
// variable
if ((empty($lang)) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$accepted = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$acceptedCnt = count($accepted);
reset($accepted);
for ($i = 0; $i < $acceptedCnt && empty($lang); $i++) {
pmaLangDetect($accepted[$i], 1);
}
}
// 2. try to findout users language by checking it's HTTP_USER_AGENT variable
if ((empty($lang)) && !empty($_SERVER['HTTP_USER_AGENT'])) {
pmaLangDetect($_SERVER['HTTP_USER_AGENT'], 2);
}
// 3. Didn't catch any valid lang : we use the default settings
if (empty($lang)) {
$lang = $cfgDefaultLang;
}
/**
* The following lines are inserted by Elpidio latorilla for CARE 2X - 19.07.2002/08:55
* to ensure that the language files are available. If not, english will be used.
*/
$lang_file = $lang_path.$lang.'/lang_'.$lang.'_nursing.php';
//echo $lang_file;
if((!file_exists($lang_file))&&(!file_exists('../'.$lang_file))){
$lang='en';
}
// save language to cookie
//setcookie("ck_lang".$sid,$lang);
?>