250 |
kaklik |
1 |
<?php |
|
|
2 |
/* $Id: select_lang.lib.php,v 2.36.2.2 2006/05/02 09:28:57 nijel Exp $ */ |
|
|
3 |
// vim: expandtab sw=4 ts=4 sts=4: |
|
|
4 |
|
|
|
5 |
/** |
|
|
6 |
* phpMyAdmin Language Loading File |
|
|
7 |
*/ |
|
|
8 |
|
|
|
9 |
/** |
|
|
10 |
* trys to find the language to use |
|
|
11 |
* |
|
|
12 |
* @uses $GLOBALS['cfg']['lang'] |
|
|
13 |
* @uses $GLOBALS['cfg']['DefaultLang'] |
|
|
14 |
* @uses $GLOBALS['lang_failed_cfg'] |
|
|
15 |
* @uses $GLOBALS['lang_failed_cookie'] |
|
|
16 |
* @uses $GLOBALS['lang_failed_request'] |
|
|
17 |
* @uses $_REQUEST['lang'] |
|
|
18 |
* @uses $_COOKIE['pma_lang'] |
|
|
19 |
* @uses $_SERVER['HTTP_ACCEPT_LANGUAGE'] |
|
|
20 |
* @uses $_SERVER['HTTP_USER_AGENT'] |
|
|
21 |
* @uses PMA_langSet() |
|
|
22 |
* @uses PMA_langDetect() |
|
|
23 |
* @uses explode() |
|
|
24 |
* @return bool success if valid lang is found, otherwise false |
|
|
25 |
*/ |
|
|
26 |
function PMA_langCheck() |
|
|
27 |
{ |
|
|
28 |
// check forced language |
|
|
29 |
if (! empty($GLOBALS['cfg']['Lang'])) { |
|
|
30 |
if (PMA_langSet($GLOBALS['cfg']['Lang'])) { |
|
|
31 |
return true; |
|
|
32 |
} else { |
|
|
33 |
$GLOBALS['lang_failed_cfg'] = $GLOBALS['cfg']['Lang']; |
|
|
34 |
} |
|
|
35 |
} |
|
|
36 |
|
|
|
37 |
// check user requested language |
|
|
38 |
if (! empty($_REQUEST['lang'])) { |
|
|
39 |
if (PMA_langSet($_REQUEST['lang'])) { |
|
|
40 |
return true; |
|
|
41 |
} else { |
|
|
42 |
$GLOBALS['lang_failed_request'] = $_REQUEST['lang']; |
|
|
43 |
} |
|
|
44 |
} |
|
|
45 |
|
|
|
46 |
// check previous set language |
|
|
47 |
if (! empty($_COOKIE['pma_lang'])) { |
|
|
48 |
if (PMA_langSet($_COOKIE['pma_lang'])) { |
|
|
49 |
return true; |
|
|
50 |
} else { |
|
|
51 |
$GLOBALS['lang_failed_cookie'] = $_COOKIE['pma_lang']; |
|
|
52 |
} |
|
|
53 |
} |
|
|
54 |
|
|
|
55 |
// try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE variable |
|
|
56 |
if (PMA_getenv('HTTP_ACCEPT_LANGUAGE')) { |
|
|
57 |
foreach (explode(',', PMA_getenv('HTTP_ACCEPT_LANGUAGE')) as $lang) { |
|
|
58 |
if (PMA_langDetect($lang, 1)) { |
|
|
59 |
return true; |
|
|
60 |
} |
|
|
61 |
} |
|
|
62 |
} |
|
|
63 |
|
|
|
64 |
// try to findout user's language by checking its HTTP_USER_AGENT variable |
|
|
65 |
if (PMA_langDetect(PMA_getenv('HTTP_USER_AGENT'), 2)) { |
|
|
66 |
return true; |
|
|
67 |
} |
|
|
68 |
|
|
|
69 |
// Didn't catch any valid lang : we use the default settings |
|
|
70 |
if (PMA_langSet($GLOBALS['cfg']['DefaultLang'])) { |
|
|
71 |
return true; |
|
|
72 |
} |
|
|
73 |
|
|
|
74 |
return false; |
|
|
75 |
} |
|
|
76 |
|
|
|
77 |
/** |
|
|
78 |
* checks given lang and sets it if valid |
|
|
79 |
* returns true on success, otherwise flase |
|
|
80 |
* |
|
|
81 |
* @uses $GLOBALS['available_languages'] to check $lang |
|
|
82 |
* @uses $GLOBALS['lang'] to set it |
|
|
83 |
* @param string $lang language to set |
|
|
84 |
* @return bool success |
|
|
85 |
*/ |
|
|
86 |
function PMA_langSet(&$lang) |
|
|
87 |
{ |
|
|
88 |
if (empty($lang) || empty($GLOBALS['available_languages'][$lang])) { |
|
|
89 |
return false; |
|
|
90 |
} |
|
|
91 |
$GLOBALS['lang'] = $lang; |
|
|
92 |
return true; |
|
|
93 |
} |
|
|
94 |
|
|
|
95 |
/** |
|
|
96 |
* Analyzes some PHP environment variables to find the most probable language |
|
|
97 |
* that should be used |
|
|
98 |
* |
|
|
99 |
* @param string string to analyze |
|
|
100 |
* @param integer type of the PHP environment variable which value is $str |
|
|
101 |
* |
|
|
102 |
* @return bool true on success, otherwise false |
|
|
103 |
* |
|
|
104 |
* @global $available_languages |
|
|
105 |
* |
|
|
106 |
* @access private |
|
|
107 |
*/ |
|
|
108 |
function PMA_langDetect(&$str, $envType) |
|
|
109 |
{ |
|
|
110 |
if (empty($str)) { |
|
|
111 |
return false; |
|
|
112 |
} |
|
|
113 |
if (empty($GLOBALS['available_languages'])) { |
|
|
114 |
return false; |
|
|
115 |
} |
|
|
116 |
|
|
|
117 |
foreach ($GLOBALS['available_languages'] as $lang => $value) { |
|
|
118 |
// $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable, |
|
|
119 |
// 2 for the 'HTTP_USER_AGENT' one |
|
|
120 |
$expr = $value[0]; |
|
|
121 |
if (strpos($expr, '[-_]') === FALSE) { |
|
|
122 |
$expr = str_replace('|', '([-_][[:alpha:]]{2,3})?|', $expr); |
|
|
123 |
} |
|
|
124 |
if (($envType == 1 && eregi('^(' . $expr . ')(;q=[0-9]\\.[0-9])?$', $str)) |
|
|
125 |
|| ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $expr . ')(;|\]|\))', $str))) { |
|
|
126 |
if (PMA_langSet($lang)) { |
|
|
127 |
return true; |
|
|
128 |
} |
|
|
129 |
} |
|
|
130 |
} |
|
|
131 |
|
|
|
132 |
return false; |
|
|
133 |
} // end of the 'PMA_langDetect()' function |
|
|
134 |
|
|
|
135 |
/** |
|
|
136 |
* @var string path to the translations directory |
|
|
137 |
*/ |
|
|
138 |
$lang_path = './lang/'; |
|
|
139 |
|
|
|
140 |
/** |
|
|
141 |
* first check for lang dir exists |
|
|
142 |
*/ |
|
|
143 |
if (! is_dir($lang_path)) { |
|
|
144 |
// language directory not found |
|
|
145 |
trigger_error('phpMyAdmin-ERROR: path not found: ' |
|
|
146 |
. $lang_path . ', check your language directory.', |
|
|
147 |
E_USER_WARNING); |
|
|
148 |
// and tell the user |
|
|
149 |
PMA_sendHeaderLocation('error.php?error=' |
|
|
150 |
. urlencode( 'path to languages is invalid: ' . $lang_path)); |
|
|
151 |
// stop execution |
|
|
152 |
exit; |
|
|
153 |
} |
|
|
154 |
|
|
|
155 |
/** |
|
|
156 |
* @var string interface language |
|
|
157 |
*/ |
|
|
158 |
$GLOBALS['lang'] = ''; |
|
|
159 |
/** |
|
|
160 |
* @var boolean wether loading lang from cfg failed |
|
|
161 |
*/ |
|
|
162 |
$lang_failed_cfg = false; |
|
|
163 |
/** |
|
|
164 |
* @var boolean wether loading lang from cookie failed |
|
|
165 |
*/ |
|
|
166 |
$lang_failed_cookie = false; |
|
|
167 |
/** |
|
|
168 |
* @var boolean wether loading lang from user request failed |
|
|
169 |
*/ |
|
|
170 |
$lang_failed_request = false; |
|
|
171 |
|
|
|
172 |
|
|
|
173 |
/** |
|
|
174 |
* All the supported languages have to be listed in the array below. |
|
|
175 |
* 1. The key must be the "official" ISO 639 language code and, if required, |
|
|
176 |
* the dialect code. It can also contain some informations about the |
|
|
177 |
* charset (see the Russian case). |
|
|
178 |
* 2. The first of the values associated to the key is used in a regular |
|
|
179 |
* expression to find some keywords corresponding to the language inside two |
|
|
180 |
* environment variables. |
|
|
181 |
* These values contains: |
|
|
182 |
* - the "official" ISO language code and, if required, the dialect code |
|
|
183 |
* also ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French |
|
|
184 |
* dialects, 'zh[-_]tw' for Chinese traditional...), the dialect has to |
|
|
185 |
* be specified as first; |
|
|
186 |
* - the '|' character (it means 'OR'); |
|
|
187 |
* - the full language name. |
|
|
188 |
* 3. The second values associated to the key is the name of the file to load |
|
|
189 |
* without the 'inc.php' extension. |
|
|
190 |
* 4. The third values associated to the key is the language code as defined by |
|
|
191 |
* the RFC1766. |
|
|
192 |
* 5. The fourth value is native name in html entities. |
|
|
193 |
* |
|
|
194 |
* Beware that the sorting order (first values associated to keys by |
|
|
195 |
* alphabetical reverse order in the array) is important: 'zh-tw' (chinese |
|
|
196 |
* traditional) must be detected before 'zh' (chinese simplified) for |
|
|
197 |
* example. |
|
|
198 |
* |
|
|
199 |
* When there are more than one charset for a language, we put the -utf-8 |
|
|
200 |
* last because we need the default charset to be non-utf-8 to avoid |
|
|
201 |
* problems on MySQL < 4.1.x if AllowAnywhereRecoding is FALSE. |
|
|
202 |
* |
|
|
203 |
* For Russian, we put 1251 first, because MSIE does not accept 866 |
|
|
204 |
* and users would not see anything. |
|
|
205 |
*/ |
|
|
206 |
$available_languages = array( |
|
|
207 |
'af-iso-8859-1' => array('af|afrikaans', 'afrikaans-iso-8859-1', 'af', ''), |
|
|
208 |
'af-utf-8' => array('af|afrikaans', 'afrikaans-utf-8', 'af', ''), |
|
|
209 |
'ar-win1256' => array('ar|arabic', 'arabic-windows-1256', 'ar', 'العربية'), |
|
|
210 |
'ar-utf-8' => array('ar|arabic', 'arabic-utf-8', 'ar', 'العربية'), |
|
|
211 |
'az-iso-8859-9' => array('az|azerbaijani', 'azerbaijani-iso-8859-9', 'az', 'Azərbaycanca'), |
|
|
212 |
'az-utf-8' => array('az|azerbaijani', 'azerbaijani-utf-8', 'az', 'Azərbaycanca'), |
|
|
213 |
|
|
|
214 |
'becyr-win1251' => array('be|belarusian', 'belarusian_cyrillic-windows-1251', 'be', 'Беларуская'), |
|
|
215 |
'becyr-utf-8' => array('be|belarusian', 'belarusian_cyrillic-utf-8', 'be', 'Беларуская'), |
|
|
216 |
'belat-utf-8' => array('be[-_]lat|belarusian latin', 'belarusian_latin-utf-8', 'be-lat', 'Byelorussian'), |
|
|
217 |
'bg-win1251' => array('bg|bulgarian', 'bulgarian-windows-1251', 'bg', 'Български'), |
|
|
218 |
'bg-koi8-r' => array('bg|bulgarian', 'bulgarian-koi8-r', 'bg', 'Български'), |
|
|
219 |
'bg-utf-8' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg', 'Български'), |
|
|
220 |
'bs-win1250' => array('bs|bosnian', 'bosnian-windows-1250', 'bs', 'Bosanski'), |
|
|
221 |
'bs-utf-8' => array('bs|bosnian', 'bosnian-utf-8', 'bs', 'Bosanski'), |
|
|
222 |
'ca-iso-8859-1' => array('ca|catalan', 'catalan-iso-8859-1', 'ca', 'Català'), |
|
|
223 |
'ca-utf-8' => array('ca|catalan', 'catalan-utf-8', 'ca', 'Català'), |
|
|
224 |
'cs-iso-8859-2' => array('cs|czech', 'czech-iso-8859-2', 'cs', 'Česky'), |
|
|
225 |
'cs-win1250' => array('cs|czech', 'czech-windows-1250', 'cs', 'Česky'), |
|
|
226 |
'cs-utf-8' => array('cs|czech', 'czech-utf-8', 'cs', 'Česky'), |
|
|
227 |
'da-iso-8859-1' => array('da|danish', 'danish-iso-8859-1', 'da', 'Dansk'), |
|
|
228 |
'da-utf-8' => array('da|danish', 'danish-utf-8', 'da', 'Dansk'), |
|
|
229 |
'de-iso-8859-1' => array('de|german', 'german-iso-8859-1', 'de', 'Deutsch'), |
|
|
230 |
'de-iso-8859-15' => array('de|german', 'german-iso-8859-15', 'de', 'Deutsch'), |
|
|
231 |
'de-utf-8' => array('de|german', 'german-utf-8', 'de', 'Deutsch'), |
|
|
232 |
'el-iso-8859-7' => array('el|greek', 'greek-iso-8859-7', 'el', 'Ελληνικά'), |
|
|
233 |
'el-utf-8' => array('el|greek', 'greek-utf-8', 'el', 'Ελληνικά'), |
|
|
234 |
'en-iso-8859-1' => array('en|english', 'english-iso-8859-1', 'en', ''), |
|
|
235 |
'en-iso-8859-15' => array('en|english', 'english-iso-8859-15', 'en', ''), |
|
|
236 |
'en-utf-8' => array('en|english', 'english-utf-8', 'en', ''), |
|
|
237 |
'es-iso-8859-1' => array('es|spanish', 'spanish-iso-8859-1', 'es', 'Español'), |
|
|
238 |
'es-iso-8859-15' => array('es|spanish', 'spanish-iso-8859-15', 'es', 'Español'), |
|
|
239 |
'es-utf-8' => array('es|spanish', 'spanish-utf-8', 'es', 'Español'), |
|
|
240 |
'et-iso-8859-1' => array('et|estonian', 'estonian-iso-8859-1', 'et', 'Eesti'), |
|
|
241 |
'et-utf-8' => array('et|estonian', 'estonian-utf-8', 'et', 'Eesti'), |
|
|
242 |
'eu-iso-8859-1' => array('eu|basque', 'basque-iso-8859-1', 'eu', 'Euskara'), |
|
|
243 |
'eu-utf-8' => array('eu|basque', 'basque-utf-8', 'eu', 'Euskara'), |
|
|
244 |
'fa-win1256' => array('fa|persian', 'persian-windows-1256', 'fa', 'فارسی'), |
|
|
245 |
'fa-utf-8' => array('fa|persian', 'persian-utf-8', 'fa', 'فارسی'), |
|
|
246 |
'fi-iso-8859-1' => array('fi|finnish', 'finnish-iso-8859-1', 'fi', 'Suomi'), |
|
|
247 |
'fi-iso-8859-15' => array('fi|finnish', 'finnish-iso-8859-15', 'fi', 'Suomi'), |
|
|
248 |
'fi-utf-8' => array('fi|finnish', 'finnish-utf-8', 'fi', 'Suomi'), |
|
|
249 |
'fr-iso-8859-1' => array('fr|french', 'french-iso-8859-1', 'fr', 'Français'), |
|
|
250 |
'fr-iso-8859-15' => array('fr|french', 'french-iso-8859-15', 'fr', 'Français'), |
|
|
251 |
'fr-utf-8' => array('fr|french', 'french-utf-8', 'fr', 'Français'), |
|
|
252 |
'gl-iso-8859-1' => array('gl|galician', 'galician-iso-8859-1', 'gl', 'Galego'), |
|
|
253 |
'gl-utf-8' => array('gl|galician', 'galician-utf-8', 'gl', 'Galego'), |
|
|
254 |
'he-iso-8859-8-i' => array('he|hebrew', 'hebrew-iso-8859-8-i', 'he', 'עברית'), |
|
|
255 |
'he-utf-8' => array('he|hebrew', 'hebrew-utf-8', 'he', 'עברית'), |
|
|
256 |
'hi-utf-8' => array('hi|hindi', 'hindi-utf-8', 'hi', 'हिन्दी'), |
|
|
257 |
'hr-win1250' => array('hr|croatian', 'croatian-windows-1250', 'hr', 'Hrvatski'), |
|
|
258 |
'hr-iso-8859-2' => array('hr|croatian', 'croatian-iso-8859-2', 'hr', 'Hrvatski'), |
|
|
259 |
'hr-utf-8' => array('hr|croatian', 'croatian-utf-8', 'hr', 'Hrvatski'), |
|
|
260 |
'hu-iso-8859-2' => array('hu|hungarian', 'hungarian-iso-8859-2', 'hu', 'Magyar'), |
|
|
261 |
'hu-utf-8' => array('hu|hungarian', 'hungarian-utf-8', 'hu', 'Magyar'), |
|
|
262 |
'id-iso-8859-1' => array('id|indonesian', 'indonesian-iso-8859-1', 'id', 'Bahasa Indonesia'), |
|
|
263 |
'id-utf-8' => array('id|indonesian', 'indonesian-utf-8', 'id', 'Bahasa Indonesia'), |
|
|
264 |
'it-iso-8859-1' => array('it|italian', 'italian-iso-8859-1', 'it', 'Italiano'), |
|
|
265 |
'it-iso-8859-15' => array('it|italian', 'italian-iso-8859-15', 'it', 'Italiano'), |
|
|
266 |
'it-utf-8' => array('it|italian', 'italian-utf-8', 'it', 'Italiano'), |
|
|
267 |
'ja-euc' => array('ja|japanese', 'japanese-euc', 'ja', '日本語'), |
|
|
268 |
'ja-sjis' => array('ja|japanese', 'japanese-sjis', 'ja', '日本語'), |
|
|
269 |
'ja-utf-8' => array('ja|japanese', 'japanese-utf-8', 'ja', '日本語'), |
|
|
270 |
'ko-euc-kr' => array('ko|korean', 'korean-euc-kr', 'ko', '한국어'), |
|
|
271 |
'ko-utf-8' => array('ko|korean', 'korean-utf-8', 'ko', '한국어'), |
|
|
272 |
'ka-utf-8' => array('ka|georgian', 'georgian-utf-8', 'ka', 'ქართული'), |
|
|
273 |
'lt-win1257' => array('lt|lithuanian', 'lithuanian-windows-1257', 'lt', 'Lietuvių'), |
|
|
274 |
'lt-utf-8' => array('lt|lithuanian', 'lithuanian-utf-8', 'lt', 'Lietuvių'), |
|
|
275 |
'lv-win1257' => array('lv|latvian', 'latvian-windows-1257', 'lv', 'Latviešu'), |
|
|
276 |
'lv-utf-8' => array('lv|latvian', 'latvian-utf-8', 'lv', 'Latviešu'), |
|
|
277 |
'mn-utf-8' => array('mn|mongolian', 'mongolian-utf-8', 'mn', 'Монгол'), |
|
|
278 |
'ms-iso-8859-1' => array('ms|malay', 'malay-iso-8859-1', 'ms', 'Bahasa Melayu'), |
|
|
279 |
'ms-utf-8' => array('ms|malay', 'malay-utf-8', 'ms', 'Bahasa Melayu'), |
|
|
280 |
'nl-iso-8859-1' => array('nl|dutch', 'dutch-iso-8859-1', 'nl', 'Nederlands'), |
|
|
281 |
'nl-iso-8859-15' => array('nl|dutch', 'dutch-iso-8859-15', 'nl', 'Nederlands'), |
|
|
282 |
'nl-utf-8' => array('nl|dutch', 'dutch-utf-8', 'nl', 'Nederlands'), |
|
|
283 |
'no-iso-8859-1' => array('no|norwegian', 'norwegian-iso-8859-1', 'no', 'Norsk'), |
|
|
284 |
'no-utf-8' => array('no|norwegian', 'norwegian-utf-8', 'no', 'Norsk'), |
|
|
285 |
'pl-iso-8859-2' => array('pl|polish', 'polish-iso-8859-2', 'pl', 'Polski'), |
|
|
286 |
'pl-win1250' => array('pl|polish', 'polish-windows-1250', 'pl', 'Polski'), |
|
|
287 |
'pl-utf-8' => array('pl|polish', 'polish-utf-8', 'pl', 'Polski'), |
|
|
288 |
'ptbr-iso-8859-1' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-iso-8859-1', 'pt-BR', 'Português'), |
|
|
289 |
'ptbr-utf-8' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-utf-8', 'pt-BR', 'Português'), |
|
|
290 |
'pt-iso-8859-1' => array('pt|portuguese', 'portuguese-iso-8859-1', 'pt', 'Português'), |
|
|
291 |
'pt-iso-8859-15' => array('pt|portuguese', 'portuguese-iso-8859-15', 'pt', 'Português'), |
|
|
292 |
'pt-utf-8' => array('pt|portuguese', 'portuguese-utf-8', 'pt', 'Português'), |
|
|
293 |
'ro-iso-8859-1' => array('ro|romanian', 'romanian-iso-8859-1', 'ro', 'Română'), |
|
|
294 |
'ro-utf-8' => array('ro|romanian', 'romanian-utf-8', 'ro', 'Română'), |
|
|
295 |
'ru-win1251' => array('ru|russian', 'russian-windows-1251', 'ru', 'Русский'), |
|
|
296 |
'ru-cp-866' => array('ru|russian', 'russian-cp-866', 'ru', 'Русский'), |
|
|
297 |
'ru-koi8-r' => array('ru|russian', 'russian-koi8-r', 'ru', 'Русский'), |
|
|
298 |
'ru-utf-8' => array('ru|russian', 'russian-utf-8', 'ru', 'Русский'), |
|
|
299 |
'sk-iso-8859-2' => array('sk|slovak', 'slovak-iso-8859-2', 'sk', 'Slovenčina'), |
|
|
300 |
'sk-win1250' => array('sk|slovak', 'slovak-windows-1250', 'sk', 'Slovenčina'), |
|
|
301 |
'sk-utf-8' => array('sk|slovak', 'slovak-utf-8', 'sk', 'Slovenčina'), |
|
|
302 |
'sl-iso-8859-2' => array('sl|slovenian', 'slovenian-iso-8859-2', 'sl', 'Slovenščina'), |
|
|
303 |
'sl-win1250' => array('sl|slovenian', 'slovenian-windows-1250', 'sl', 'Slovenščina'), |
|
|
304 |
'sl-utf-8' => array('sl|slovenian', 'slovenian-utf-8', 'sl', 'Slovenščina'), |
|
|
305 |
'sq-iso-8859-1' => array('sq|albanian', 'albanian-iso-8859-1', 'sq', 'Shqip'), |
|
|
306 |
'sq-utf-8' => array('sq|albanian', 'albanian-utf-8', 'sq', 'Shqip'), |
|
|
307 |
'srlat-win1250' => array('sr[-_]lat|serbian latin', 'serbian_latin-windows-1250', 'sr-lat', 'Srpski'), |
|
|
308 |
'srlat-utf-8' => array('sr[-_]lat|serbian latin', 'serbian_latin-utf-8', 'sr-lat', 'Srpski'), |
|
|
309 |
'srcyr-win1251' => array('sr|serbian', 'serbian_cyrillic-windows-1251', 'sr', 'Српски'), |
|
|
310 |
'srcyr-utf-8' => array('sr|serbian', 'serbian_cyrillic-utf-8', 'sr', 'Српски'), |
|
|
311 |
'sv-iso-8859-1' => array('sv|swedish', 'swedish-iso-8859-1', 'sv', 'Svenska'), |
|
|
312 |
'sv-utf-8' => array('sv|swedish', 'swedish-utf-8', 'sv', 'Svenska'), |
|
|
313 |
'th-tis-620' => array('th|thai', 'thai-tis-620', 'th', 'ภาษาไทย'), |
|
|
314 |
'th-utf-8' => array('th|thai', 'thai-utf-8', 'th', 'ภาษาไทย'), |
|
|
315 |
'tr-iso-8859-9' => array('tr|turkish', 'turkish-iso-8859-9', 'tr', 'Türkçe'), |
|
|
316 |
'tr-utf-8' => array('tr|turkish', 'turkish-utf-8', 'tr', 'Türkçe'), |
|
|
317 |
'tt-iso-8859-9' => array('tt|tatarish', 'tatarish-iso-8859-9', 'tt', 'Tatar'), |
|
|
318 |
'tt-utf-8' => array('tt|tatarish', 'tatarish-utf-8', 'tt', 'Tatar'), |
|
|
319 |
'uk-win1251' => array('uk|ukrainian', 'ukrainian-windows-1251', 'uk', 'Українська'), |
|
|
320 |
'uk-utf-8' => array('uk|ukrainian', 'ukrainian-utf-8', 'uk', 'Українська'), |
|
|
321 |
'zhtw-big5' => array('zh[-_](tw|hk)|chinese traditional', 'chinese_traditional-big5', 'zh-TW', '中文'), |
|
|
322 |
'zhtw-utf-8' => array('zh[-_](tw|hk)|chinese traditional', 'chinese_traditional-utf-8', 'zh-TW', '中文'), |
|
|
323 |
'zh-gb2312' => array('zh|chinese simplified', 'chinese_simplified-gb2312', 'zh', '中文'), |
|
|
324 |
'zh-utf-8' => array('zh|chinese simplified', 'chinese_simplified-utf-8', 'zh', '中文'), |
|
|
325 |
); |
|
|
326 |
|
|
|
327 |
// Language filtering support |
|
|
328 |
if (! empty($GLOBALS['cfg']['FilterLanguages'])) { |
|
|
329 |
$new_lang = array(); |
|
|
330 |
foreach ($available_languages as $key => $val) { |
|
|
331 |
if (preg_match('@' . $GLOBALS['cfg']['FilterLanguages'] . '@', $key)) { |
|
|
332 |
$new_lang[$key] = $val; |
|
|
333 |
} |
|
|
334 |
} |
|
|
335 |
if (count($new_lang) > 0) { |
|
|
336 |
$available_languages = $new_lang; |
|
|
337 |
} |
|
|
338 |
unset($key, $val, $new_lang); |
|
|
339 |
} |
|
|
340 |
|
|
|
341 |
/** |
|
|
342 |
* check for language files |
|
|
343 |
*/ |
|
|
344 |
foreach ($available_languages as $each_lang_key => $each_lang) { |
|
|
345 |
if (! file_exists($lang_path . $each_lang[1] . '.inc.php')) { |
|
|
346 |
unset($available_languages[$each_lang_key]); |
|
|
347 |
} |
|
|
348 |
} |
|
|
349 |
unset($each_lang_key, $each_lang); |
|
|
350 |
|
|
|
351 |
// MySQL charsets map |
|
|
352 |
$mysql_charset_map = array( |
|
|
353 |
'big5' => 'big5', |
|
|
354 |
'cp-866' => 'cp866', |
|
|
355 |
'euc-jp' => 'ujis', |
|
|
356 |
'euc-kr' => 'euckr', |
|
|
357 |
'gb2312' => 'gb2312', |
|
|
358 |
'gbk' => 'gbk', |
|
|
359 |
'iso-8859-1' => 'latin1', |
|
|
360 |
'iso-8859-2' => 'latin2', |
|
|
361 |
'iso-8859-7' => 'greek', |
|
|
362 |
'iso-8859-8' => 'hebrew', |
|
|
363 |
'iso-8859-8-i' => 'hebrew', |
|
|
364 |
'iso-8859-9' => 'latin5', |
|
|
365 |
'iso-8859-13' => 'latin7', |
|
|
366 |
'iso-8859-15' => 'latin1', |
|
|
367 |
'koi8-r' => 'koi8r', |
|
|
368 |
'shift_jis' => 'sjis', |
|
|
369 |
'tis-620' => 'tis620', |
|
|
370 |
'utf-8' => 'utf8', |
|
|
371 |
'windows-1250' => 'cp1250', |
|
|
372 |
'windows-1251' => 'cp1251', |
|
|
373 |
'windows-1252' => 'latin1', |
|
|
374 |
'windows-1256' => 'cp1256', |
|
|
375 |
'windows-1257' => 'cp1257', |
|
|
376 |
); |
|
|
377 |
|
|
|
378 |
/** |
|
|
379 |
* Do the work! |
|
|
380 |
*/ |
|
|
381 |
// Checks whether charset recoding should be allowed or not |
|
|
382 |
$allow_recoding = FALSE; // Default fallback value |
|
|
383 |
if (empty($convcharset)) { |
|
|
384 |
if (isset($_COOKIE['pma_charset'])) { |
|
|
385 |
$convcharset = $_COOKIE['pma_charset']; |
|
|
386 |
} else { |
|
|
387 |
$convcharset = $GLOBALS['cfg']['DefaultCharset']; |
|
|
388 |
} |
|
|
389 |
} |
|
|
390 |
|
|
|
391 |
if (! PMA_langCheck()) { |
|
|
392 |
// fallback language |
|
|
393 |
$fall_back_lang = 'en-utf-8'; $line = __LINE__; |
|
|
394 |
if (! PMA_langSet($fall_back_lang)) { |
|
|
395 |
trigger_error('phpMyAdmin-ERROR: invalid lang code: ' |
|
|
396 |
. __FILE__ . '#' . $line . ', check hard coded fall back language.', |
|
|
397 |
E_USER_WARNING); |
|
|
398 |
// stop execution |
|
|
399 |
// and tell the user that his choosen language is invalid |
|
|
400 |
PMA_sendHeaderLocation('error.php?error=' |
|
|
401 |
. urlencode('Could not load any language, please check your language settings and folder')); |
|
|
402 |
exit; |
|
|
403 |
} |
|
|
404 |
} |
|
|
405 |
|
|
|
406 |
// Defines the associated filename and load the translation |
|
|
407 |
$lang_file = $lang_path . $available_languages[$GLOBALS['lang']][1] . '.inc.php'; |
|
|
408 |
require_once($lang_file); |
|
|
409 |
|
|
|
410 |
// now, that we have loaded the language strings we can send the errors |
|
|
411 |
if ($lang_failed_cfg) { |
|
|
412 |
$GLOBALS['PMA_errors'][] = sprintf($strLanguageUnknown, htmlspecialchars($lang_failed_cfg)); |
|
|
413 |
} |
|
|
414 |
if ($lang_failed_cookie) { |
|
|
415 |
$GLOBALS['PMA_errors'][] = sprintf($strLanguageUnknown, htmlspecialchars($lang_failed_cookie)); |
|
|
416 |
} |
|
|
417 |
if ($lang_failed_request) { |
|
|
418 |
$GLOBALS['PMA_errors'][] = sprintf($strLanguageUnknown, htmlspecialchars($lang_failed_request)); |
|
|
419 |
} |
|
|
420 |
|
|
|
421 |
unset($lang_file, $lang_path, $strLanguageFileNotFound, $line, $fall_back_lang, |
|
|
422 |
$lang_failed_cfg, $lang_failed_cookie, $lang_failed_request, $strLanguageUnknown); |
|
|
423 |
?> |