59177427 |
1 | <?php |
35586184 |
2 | /** |
d3bab52e |
3 | * SquirrelMail internationalization functions |
35586184 |
4 | * |
2ba706ef |
5 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
35586184 |
6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | * |
8 | * This file contains variuos functions that are needed to do |
9 | * internationalization of SquirrelMail. |
10 | * |
11 | * Internally the output character set is used. Other characters are |
12 | * encoded using Unicode entities according to HTML 4.0. |
13 | * |
a8a1c36d |
14 | * @version $Id$ |
d6c32258 |
15 | * @package squirrelmail |
a8a1c36d |
16 | * @subpackage i18n |
35586184 |
17 | */ |
18 | |
d6c32258 |
19 | /** Everything uses global.php... */ |
961ca3d8 |
20 | require_once(SM_PATH . 'functions/global.php'); |
21 | |
3b84e1b1 |
22 | /** |
23 | * Gettext bindtextdomain wrapper. |
24 | * |
25 | * Wrapper solves differences between php versions in order to provide |
26 | * ngettext support. Should be used if translation uses ngettext |
27 | * functions. |
81be3f39 |
28 | * @since 1.5.1 |
3b84e1b1 |
29 | * @param string $domain gettext domain name |
30 | * @param string $dir directory that contains all translations |
31 | * @return string path to translation directory |
32 | */ |
33 | function sq_bindtextdomain($domain,$dir) { |
34 | global $l10n, $gettext_flags, $sm_notAlias; |
35 | |
36 | if ($gettext_flags==7) { |
37 | // gettext extension without ngettext |
38 | if (substr($dir, -1) != '/') $dir .= '/'; |
39 | $mofile=$dir . $sm_notAlias . '/LC_MESSAGES/' . $domain . '.mo'; |
40 | $input = new FileReader($mofile); |
41 | $l10n[$domain] = new gettext_reader($input); |
42 | } |
43 | |
44 | $dir=bindtextdomain($domain,$dir); |
45 | |
46 | return $dir; |
47 | } |
48 | |
49 | /** |
50 | * Gettext textdomain wrapper. |
51 | * Makes sure that gettext_domain global is modified. |
81be3f39 |
52 | * @since 1.5.1 |
3b84e1b1 |
53 | * @param string $name gettext domain name |
54 | * @return string gettext domain name |
55 | */ |
56 | function sq_textdomain($domain) { |
57 | global $gettext_domain; |
58 | $gettext_domain=textdomain($domain); |
59 | return $gettext_domain; |
60 | } |
61 | |
d6c32258 |
62 | /** |
51468260 |
63 | * Converts string from given charset to charset, that can be displayed by user translation. |
64 | * |
65 | * Function by default returns html encoded strings, if translation uses different encoding. |
66 | * If Japanese translation is used - function returns string converted to euc-jp |
67 | * If iconv or recode functions are enabled and translation uses utf-8 - function returns utf-8 encoded string. |
68 | * If $charset is not supported - function returns unconverted string. |
62f7daa5 |
69 | * |
51468260 |
70 | * sanitizing of html tags is also done by this function. |
71 | * |
d6c32258 |
72 | * @param string $charset |
73 | * @param string $string Text to be decoded |
51468260 |
74 | * @return string decoded string |
d6c32258 |
75 | */ |
a2a7852b |
76 | function charset_decode ($charset, $string) { |
3ec81e63 |
77 | global $languages, $squirrelmail_language, $default_charset; |
f03f6ee7 |
78 | global $use_php_recode, $use_php_iconv, $aggressive_decoding; |
a2a7852b |
79 | |
3714db45 |
80 | if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && |
1bb86586 |
81 | function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode')) { |
82 | $string = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $string); |
6fbd125b |
83 | } |
b05c8961 |
84 | |
3ec81e63 |
85 | $charset = strtolower($charset); |
86 | |
87 | set_my_charset(); |
88 | |
89 | // Variables that allow to use functions without function_exist() calls |
edf2c0ba |
90 | if (! isset($use_php_recode) || $use_php_recode=="" ) { |
3b84e1b1 |
91 | $use_php_recode=false; } |
edf2c0ba |
92 | if (! isset($use_php_iconv) || $use_php_iconv=="" ) { |
3b84e1b1 |
93 | $use_php_iconv=false; } |
3ec81e63 |
94 | |
95 | // Don't do conversion if charset is the same. |
96 | if ( $charset == strtolower($default_charset) ) |
3b84e1b1 |
97 | return htmlspecialchars($string); |
3ec81e63 |
98 | |
99 | // catch iso-8859-8-i thing |
100 | if ( $charset == "iso-8859-8-i" ) |
3b84e1b1 |
101 | $charset = "iso-8859-8"; |
3ec81e63 |
102 | |
103 | /* |
62f7daa5 |
104 | * Recode converts html special characters automatically if you use |
105 | * 'charset..html' decoding. There is no documented way to put -d option |
3ec81e63 |
106 | * into php recode function call. |
107 | */ |
108 | if ( $use_php_recode ) { |
3b84e1b1 |
109 | if ( $default_charset == "utf-8" ) { |
110 | // other charsets can be converted to utf-8 without loss. |
111 | // and output string is smaller |
112 | $string = recode_string($charset . "..utf-8",$string); |
113 | return htmlspecialchars($string); |
114 | } else { |
115 | $string = recode_string($charset . "..html",$string); |
116 | // recode does not convert single quote, htmlspecialchars does. |
117 | $string = str_replace("'", ''', $string); |
118 | return $string; |
119 | } |
3ec81e63 |
120 | } |
121 | |
122 | // iconv functions does not have html target and can be used only with utf-8 |
123 | if ( $use_php_iconv && $default_charset=='utf-8') { |
3b84e1b1 |
124 | $string = iconv($charset,$default_charset,$string); |
125 | return htmlspecialchars($string); |
3ec81e63 |
126 | } |
127 | |
128 | // If we don't use recode and iconv, we'll do it old way. |
129 | |
a2a7852b |
130 | /* All HTML special characters are 7 bit and can be replaced first */ |
62f7daa5 |
131 | |
098ea084 |
132 | $string = htmlspecialchars ($string); |
a2a7852b |
133 | |
5dd23dac |
134 | /* controls cpu and memory intensive decoding cycles */ |
f03f6ee7 |
135 | if (! isset($aggressive_decoding) || $aggressive_decoding=="" ) { |
3b84e1b1 |
136 | $aggressive_decoding=false; } |
5dd23dac |
137 | |
b142de74 |
138 | $decode=fixcharset($charset); |
139 | $decodefile=SM_PATH . 'functions/decode/' . $decode . '.php'; |
140 | if (file_exists($decodefile)) { |
3b84e1b1 |
141 | include_once($decodefile); |
142 | $ret = call_user_func('charset_decode_'.$decode, $string); |
a2a7852b |
143 | } else { |
3b84e1b1 |
144 | $ret = $string; |
a2a7852b |
145 | } |
146 | return( $ret ); |
147 | } |
03db90bc |
148 | |
d3bab52e |
149 | /** |
150 | * Converts html string to given charset |
81be3f39 |
151 | * @since 1.5.1 |
d3bab52e |
152 | * @param string $string |
153 | * @param string $charset |
78be8403 |
154 | * @param boolean $htmlencode keep htmlspecialchars encoding |
62f7daa5 |
155 | * @param string |
d3bab52e |
156 | */ |
78be8403 |
157 | function charset_encode($string,$charset,$htmlencode=true) { |
3b84e1b1 |
158 | global $default_charset; |
159 | |
160 | // Undo html special chars |
161 | if (! $htmlencode ) { |
162 | $string = str_replace(array('&','>','<','"'),array('&','>','<','"'),$string); |
163 | } |
164 | |
165 | $encode=fixcharset($charset); |
166 | $encodefile=SM_PATH . 'functions/encode/' . $encode . '.php'; |
167 | if (file_exists($encodefile)) { |
168 | include_once($encodefile); |
169 | $ret = call_user_func('charset_encode_'.$encode, $string); |
170 | } else { |
171 | include_once(SM_PATH . 'functions/encode/us_ascii.php'); |
172 | $ret = charset_encode_us_ascii($string); |
173 | } |
174 | return( $ret ); |
d3bab52e |
175 | } |
176 | |
177 | /** |
178 | * Combined decoding and encoding functions |
179 | * |
180 | * If conversion is done to charset different that utf-8, unsupported symbols |
181 | * will be replaced with question marks. |
81be3f39 |
182 | * @since 1.5.1 |
d3bab52e |
183 | * @param string $in_charset initial charset |
184 | * @param string $string string that has to be converted |
185 | * @param string $out_charset final charset |
78be8403 |
186 | * @param boolean $htmlencode keep htmlspecialchars encoding |
d3bab52e |
187 | * @return string converted string |
188 | */ |
78be8403 |
189 | function charset_convert($in_charset,$string,$out_charset,$htmlencode=true) { |
33991968 |
190 | $string=charset_decode($in_charset,$string); |
191 | $string=charset_encode($string,$out_charset,$htmlencode); |
192 | return $string; |
d3bab52e |
193 | } |
194 | |
b142de74 |
195 | /** |
196 | * Makes charset name suitable for decoding cycles |
197 | * |
81be3f39 |
198 | * @since 1.5.0 |
b142de74 |
199 | * @param string $charset Name of charset |
200 | * @return string $charset Adjusted name of charset |
201 | */ |
202 | function fixcharset($charset) { |
203 | // minus removed from function names |
204 | $charset=str_replace('-','_',$charset); |
62f7daa5 |
205 | |
b142de74 |
206 | // windows-125x and cp125x charsets |
207 | $charset=str_replace('windows_','cp',$charset); |
a2a7852b |
208 | |
b142de74 |
209 | // ibm > cp |
210 | $charset=str_replace('ibm','cp',$charset); |
211 | |
212 | // iso-8859-8-i -> iso-8859-8 |
213 | // use same cycle until I'll find differences |
214 | $charset=str_replace('iso_8859_8_i','iso_8859_8',$charset); |
215 | |
216 | return $charset; |
217 | } |
a2a7852b |
218 | |
51468260 |
219 | /** |
a2a7852b |
220 | * Set up the language to be output |
221 | * if $do_search is true, then scan the browser information |
222 | * for a possible language that we know |
51468260 |
223 | * |
62f7daa5 |
224 | * Function sets system locale environment (LC_ALL, LANG, LANGUAGE), |
51468260 |
225 | * gettext translation bindings and html header information. |
226 | * |
5679405c |
227 | * Function returns error codes, if there is some fatal error. |
62f7daa5 |
228 | * 0 = no error, |
229 | * 1 = mbstring support is not present, |
51468260 |
230 | * 2 = mbstring support is not present, user's translation reverted to en_US. |
231 | * |
232 | * @param string $sm_language translation used by user's interface |
233 | * @param bool $do_search use browser's preferred language detection functions. Defaults to false. |
234 | * @param bool $default set $sm_language to $squirrelmail_default_language if language detection fails or language is not set. Defaults to false. |
62f7daa5 |
235 | * @return int function execution error codes. |
a2a7852b |
236 | */ |
67a8c90a |
237 | function set_up_language($sm_language, $do_search = false, $default = false) { |
a2a7852b |
238 | |
239 | static $SetupAlready = 0; |
9eb0fbd4 |
240 | global $use_gettext, $languages, |
fe48c808 |
241 | $squirrelmail_language, $squirrelmail_default_language, $default_charset, |
51468260 |
242 | $sm_notAlias, $username, $data_dir; |
a2a7852b |
243 | |
244 | if ($SetupAlready) { |
245 | return; |
246 | } |
a65846a7 |
247 | |
5c920668 |
248 | $SetupAlready = TRUE; |
961ca3d8 |
249 | sqgetGlobalVar('HTTP_ACCEPT_LANGUAGE', $accept_lang, SQ_SERVER); |
a2a7852b |
250 | |
961ca3d8 |
251 | if ($do_search && ! $sm_language && isset($accept_lang)) { |
252 | $sm_language = substr($accept_lang, 0, 2); |
a2a7852b |
253 | } |
62f7daa5 |
254 | |
67a8c90a |
255 | if ((!$sm_language||$default) && isset($squirrelmail_default_language)) { |
a2a7852b |
256 | $squirrelmail_language = $squirrelmail_default_language; |
66d7950f |
257 | $sm_language = $squirrelmail_default_language; |
a2a7852b |
258 | } |
259 | $sm_notAlias = $sm_language; |
62f7daa5 |
260 | |
3ec81e63 |
261 | // Catching removed translation |
262 | // System reverts to English translation if user prefs contain translation |
2ba706ef |
263 | // that is not available in $languages array |
3ec81e63 |
264 | if (!isset($languages[$sm_notAlias])) { |
3b84e1b1 |
265 | $sm_notAlias="en_US"; |
3ec81e63 |
266 | } |
267 | |
a2a7852b |
268 | while (isset($languages[$sm_notAlias]['ALIAS'])) { |
269 | $sm_notAlias = $languages[$sm_notAlias]['ALIAS']; |
270 | } |
271 | |
88cb1b4d |
272 | if ( isset($sm_language) && |
5c920668 |
273 | $use_gettext && |
274 | $sm_language != '' && |
275 | isset($languages[$sm_notAlias]['CHARSET']) ) { |
3b84e1b1 |
276 | sq_bindtextdomain( 'squirrelmail', SM_PATH . 'locale/' ); |
277 | sq_textdomain( 'squirrelmail' ); |
03db90bc |
278 | if (function_exists('bind_textdomain_codeset')) { |
3b84e1b1 |
279 | if ($sm_notAlias == 'ja_JP') { |
280 | bind_textdomain_codeset ("squirrelmail", 'EUC-JP'); |
a5970d71 |
281 | } else { |
3b84e1b1 |
282 | bind_textdomain_codeset ("squirrelmail", $languages[$sm_notAlias]['CHARSET'] ); |
03db90bc |
283 | } |
284 | } |
285 | if (isset($languages[$sm_notAlias]['LOCALE'])){ |
3b84e1b1 |
286 | $longlocale=$languages[$sm_notAlias]['LOCALE']; |
03db90bc |
287 | } else { |
3b84e1b1 |
288 | $longlocale=$sm_notAlias; |
03db90bc |
289 | } |
88cb1b4d |
290 | if ( !ini_get('safe_mode') && |
f2374580 |
291 | getenv( 'LC_ALL' ) != $longlocale ) { |
292 | putenv( "LC_ALL=$longlocale" ); |
293 | putenv( "LANG=$longlocale" ); |
294 | putenv( "LANGUAGE=$longlocale" ); |
54b168cf |
295 | putenv( "LC_NUMERIC=C" ); |
475df436 |
296 | if ($sm_notAlias=='tr_TR') putenv( "LC_CTYPE=C" ); |
a2a7852b |
297 | } |
03db90bc |
298 | setlocale(LC_ALL, $longlocale); |
54b168cf |
299 | // Workaround for plugins that use numbers with floating point |
300 | // It might be removed if plugins use correct decimal delimiters |
301 | // according to locale settings. |
302 | setlocale(LC_NUMERIC, 'C'); |
303 | // Workaround for specific Turkish strtolower/strtoupper rules. |
304 | // Many functions expect English conversion rules. |
475df436 |
305 | if ($sm_notAlias=='tr_TR') setlocale(LC_CTYPE,'C'); |
03db90bc |
306 | |
307 | // Set text direction/alignment variables |
8d8da447 |
308 | // These don't appear to be used... are they safe to remove? |
62f7daa5 |
309 | if (isset($languages[$sm_notAlias]['DIR']) && |
03db90bc |
310 | $languages[$sm_notAlias]['DIR'] == 'rtl') { |
3b84e1b1 |
311 | /** |
312 | * Text direction |
313 | * @global string $text_direction |
314 | */ |
315 | $text_direction='rtl'; |
316 | /** |
317 | * Left alignment |
318 | * @global string $left_align |
319 | */ |
320 | $left_align='right'; |
321 | /** |
322 | * Right alignment |
323 | * @global string $right_align |
324 | */ |
325 | $right_align='left'; |
03db90bc |
326 | } else { |
3b84e1b1 |
327 | $text_direction='ltr'; |
328 | $left_align='left'; |
329 | $right_align='right'; |
03db90bc |
330 | } |
331 | |
332 | $squirrelmail_language = $sm_notAlias; |
a5970d71 |
333 | if ($squirrelmail_language == 'ja_JP') { |
b05c8961 |
334 | header ('Content-Type: text/html; charset=EUC-JP'); |
335 | if (!function_exists('mb_internal_encoding')) { |
3b84e1b1 |
336 | // Error messages can't be displayed here |
337 | $error = 1; |
338 | // Revert to English if possible. |
339 | if (function_exists('setPref') && $username!='' && $data_dir!="") { |
340 | setPref($data_dir, $username, 'language', "en_US"); |
341 | $error = 2; |
342 | } |
343 | // stop further execution in order not to get php errors on mb_internal_encoding(). |
344 | return $error; |
e842b215 |
345 | } |
346 | if (function_exists('mb_language')) { |
347 | mb_language('Japanese'); |
b05c8961 |
348 | } |
349 | mb_internal_encoding('EUC-JP'); |
350 | mb_http_output('pass'); |
fe48c808 |
351 | } elseif ($squirrelmail_language == 'en_US') { |
352 | header( 'Content-Type: text/html; charset=' . $default_charset ); |
b05c8961 |
353 | } else { |
fe48c808 |
354 | header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] ); |
355 | } |
a2a7852b |
356 | } |
51468260 |
357 | return 0; |
b05c8961 |
358 | } |
a2a7852b |
359 | |
51468260 |
360 | /** |
361 | * Sets default_charset variable according to the one that is used by user's translations. |
362 | * |
363 | * Function changes global $default_charset variable in order to be sure, that it |
364 | * contains charset used by user's translation. Sanity of $squirrelmail_default_language |
365 | * and $default_charset combination provided in SquirrelMail config is also tested. |
366 | * |
367 | * There can be a $default_charset setting in the |
368 | * config.php file, but the user may have a different language |
369 | * selected for a user interface. This function checks the |
370 | * language selected by the user and tags the outgoing messages |
371 | * with the appropriate charset corresponding to the language |
372 | * selection. This is "more right" (tm), than just stamping the |
373 | * message blindly with the system-wide $default_charset. |
374 | */ |
a2a7852b |
375 | function set_my_charset(){ |
94965562 |
376 | global $data_dir, $username, $default_charset, $languages, $squirrelmail_default_language; |
88cb1b4d |
377 | |
a2a7852b |
378 | $my_language = getPref($data_dir, $username, 'language'); |
5c920668 |
379 | if (!$my_language) { |
94965562 |
380 | $my_language = $squirrelmail_default_language ; |
5c920668 |
381 | } |
3ec81e63 |
382 | // Catch removed translation |
383 | if (!isset($languages[$my_language])) { |
3b84e1b1 |
384 | $my_language="en_US"; |
3ec81e63 |
385 | } |
a2a7852b |
386 | while (isset($languages[$my_language]['ALIAS'])) { |
f7e8861e |
387 | $my_language = $languages[$my_language]['ALIAS']; |
a2a7852b |
388 | } |
5c920668 |
389 | $my_charset = $languages[$my_language]['CHARSET']; |
fe48c808 |
390 | if ($my_language!='en_US') { |
a2a7852b |
391 | $default_charset = $my_charset; |
392 | } |
393 | } |
394 | |
e0e1b169 |
395 | /************************** |
396 | * Japanese extra functions |
397 | **************************/ |
a2a7852b |
398 | |
e0e1b169 |
399 | /** |
400 | * Japanese decoding function |
401 | * |
402 | * converts string to euc-jp, if string uses JIS, EUC-JP, ShiftJIS or UTF-8 |
403 | * charset. Needs mbstring support in php. |
404 | * @param string $ret text, that has to be converted |
405 | * @return string converted string |
406 | * @since 1.5.1 |
407 | */ |
408 | function japanese_xtra_decode($ret) { |
409 | if (function_exists('mb_detect_encoding')) { |
410 | $detect_encoding = @mb_detect_encoding($ret); |
411 | if ($detect_encoding == 'JIS' || |
412 | $detect_encoding == 'EUC-JP' || |
413 | $detect_encoding == 'SJIS' || |
414 | $detect_encoding == 'UTF-8') { |
5c920668 |
415 | |
e0e1b169 |
416 | $ret = mb_convert_kana(mb_convert_encoding($ret, 'EUC-JP', 'AUTO'), "KV"); |
417 | } |
418 | } |
419 | return $ret; |
a2a7852b |
420 | } |
421 | |
51468260 |
422 | /** |
e0e1b169 |
423 | * Japanese encoding function |
51468260 |
424 | * |
e0e1b169 |
425 | * converts string to jis, if string uses JIS, EUC-JP, ShiftJIS or UTF-8 |
426 | * charset. Needs mbstring support in php. |
427 | * @param string $ret text, that has to be converted |
428 | * @return string converted text |
429 | * @since 1.5.1 |
51468260 |
430 | */ |
e0e1b169 |
431 | function japanese_xtra_encode($ret) { |
432 | if (function_exists('mb_detect_encoding')) { |
433 | $detect_encoding = @mb_detect_encoding($ret); |
434 | if ($detect_encoding == 'JIS' || |
435 | $detect_encoding == 'EUC-JP' || |
436 | $detect_encoding == 'SJIS' || |
437 | $detect_encoding == 'UTF-8') { |
a8fa8e33 |
438 | |
e0e1b169 |
439 | $ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO'); |
440 | } |
441 | } |
442 | return $ret; |
443 | } |
a8fa8e33 |
444 | |
e0e1b169 |
445 | /** |
446 | * Japanese header encoding function |
447 | * |
448 | * creates base64 encoded header in iso-2022-jp charset |
449 | * @param string $ret text, that has to be converted |
450 | * @return string mime base64 encoded string |
451 | * @since 1.5.1 |
452 | */ |
453 | function japanese_xtra_encodeheader($ret) { |
454 | if (function_exists('mb_detect_encoding')) { |
455 | $result = ''; |
456 | if (strlen($ret) > 0) { |
457 | $tmpstr = mb_substr($ret, 0, 1); |
458 | $prevcsize = strlen($tmpstr); |
459 | for ($i = 1; $i < mb_strlen($ret); $i++) { |
460 | $tmp = mb_substr($ret, $i, 1); |
461 | if (strlen($tmp) == $prevcsize) { |
462 | $tmpstr .= $tmp; |
463 | } else { |
464 | if ($prevcsize == 1) { |
465 | $result .= $tmpstr; |
466 | } else { |
467 | $result .= str_replace(' ', '', |
468 | mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); |
469 | } |
470 | $tmpstr = $tmp; |
471 | $prevcsize = strlen($tmp); |
472 | } |
473 | } |
474 | if (strlen($tmpstr)) { |
475 | if (strlen(mb_substr($tmpstr, 0, 1)) == 1) |
476 | $result .= $tmpstr; |
477 | else |
478 | $result .= str_replace(' ', '', |
479 | mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); |
480 | } |
481 | } |
482 | $ret = $result; |
483 | } |
484 | return $ret; |
485 | } |
a8fa8e33 |
486 | |
e0e1b169 |
487 | /** |
488 | * Japanese header decoding function |
489 | * |
490 | * return human readable string from mime header. string is returned in euc-jp |
491 | * charset. |
492 | * @param string $ret header string |
493 | * @return string decoded header string |
494 | * @since 1.5.1 |
495 | */ |
496 | function japanese_xtra_decodeheader($ret) { |
497 | if (function_exists('mb_detect_encoding')) { |
498 | $ret = str_replace("\t", "", $ret); |
499 | if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', $ret)) |
500 | $ret = @mb_decode_mimeheader($ret); |
501 | $ret = @mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
502 | } |
503 | return $ret; |
504 | } |
a8fa8e33 |
505 | |
e0e1b169 |
506 | /** |
507 | * Japanese downloaded filename processing function |
508 | * |
509 | * Returns shift-jis or euc-jp encoded file name |
510 | * @param string $ret string |
511 | * @param string $useragent browser |
512 | * @return string converted string |
513 | * @since 1.5.1 |
514 | */ |
515 | function japanese_xtra_downloadfilename($ret,$useragent) { |
516 | if (function_exists('mb_detect_encoding')) { |
517 | if (strstr($useragent, 'Windows') !== false || |
518 | strstr($useragent, 'Mac_') !== false) { |
519 | $ret = mb_convert_encoding($ret, 'SJIS', 'AUTO'); |
520 | } else { |
521 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
522 | } |
523 | } |
524 | return $ret; |
525 | } |
a2a7852b |
526 | |
e0e1b169 |
527 | /** |
528 | * Japanese wordwrap function |
529 | * |
530 | * wraps text at set number of symbols |
531 | * @param string $ret text |
532 | * @param integer $wrap number of symbols per line |
533 | * @return string wrapped text |
534 | * @since 1.5.1 |
535 | */ |
536 | function japanese_xtra_wordwrap($ret,$wrap) { |
537 | if (function_exists('mb_detect_encoding')) { |
538 | $no_begin = "\x21\x25\x29\x2c\x2e\x3a\x3b\x3f\x5d\x7d\xa1\xf1\xa1\xeb\xa1" . |
539 | "\xc7\xa1\xc9\xa2\xf3\xa1\xec\xa1\xed\xa1\xee\xa1\xa2\xa1\xa3\xa1\xb9" . |
540 | "\xa1\xd3\xa1\xd5\xa1\xd7\xa1\xd9\xa1\xdb\xa1\xcd\xa4\xa1\xa4\xa3\xa4" . |
541 | "\xa5\xa4\xa7\xa4\xa9\xa4\xc3\xa4\xe3\xa4\xe5\xa4\xe7\xa4\xee\xa1\xab" . |
542 | "\xa1\xac\xa1\xb5\xa1\xb6\xa5\xa1\xa5\xa3\xa5\xa5\xa5\xa7\xa5\xa9\xa5" . |
543 | "\xc3\xa5\xe3\xa5\xe5\xa5\xe7\xa5\xee\xa5\xf5\xa5\xf6\xa1\xa6\xa1\xbc" . |
544 | "\xa1\xb3\xa1\xb4\xa1\xaa\xa1\xf3\xa1\xcb\xa1\xa4\xa1\xa5\xa1\xa7\xa1" . |
545 | "\xa8\xa1\xa9\xa1\xcf\xa1\xd1"; |
8d8da447 |
546 | // This don't appear to be used... is it safe to remove? |
e0e1b169 |
547 | $no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" . |
548 | "\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef"; |
3bb3d83b |
549 | |
e0e1b169 |
550 | if (strlen($ret) >= $wrap && |
551 | substr($ret, 0, 1) != '>' && |
552 | strpos($ret, 'http://') === FALSE && |
553 | strpos($ret, 'https://') === FALSE && |
554 | strpos($ret, 'ftp://') === FALSE) { |
a2a7852b |
555 | |
e0e1b169 |
556 | $ret = mb_convert_kana($ret, "KV"); |
a8fa8e33 |
557 | |
e0e1b169 |
558 | $line_new = ''; |
559 | $ptr = 0; |
a8fa8e33 |
560 | |
e0e1b169 |
561 | while ($ptr < strlen($ret) - 1) { |
562 | $l = mb_strcut($ret, $ptr, $wrap); |
563 | $ptr += strlen($l); |
564 | $tmp = $l; |
2d268514 |
565 | |
e0e1b169 |
566 | $l = mb_strcut($ret, $ptr, 2); |
567 | while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) { |
568 | $tmp .= $l; |
569 | $ptr += strlen($l); |
570 | $l = mb_strcut($ret, $ptr, 1); |
571 | } |
572 | $line_new .= $tmp; |
573 | if ($ptr < strlen($ret) - 1) |
574 | $line_new .= "\n"; |
575 | } |
576 | $ret = $line_new; |
577 | } |
578 | } |
579 | return $ret; |
580 | } |
a8fa8e33 |
581 | |
e0e1b169 |
582 | /** |
583 | * Japanese imap folder name encoding function |
584 | * |
585 | * converts folder name from euc-jp to utf7-imap |
586 | * @param string $ret folder name |
587 | * @return string converted folder name |
588 | * @since 1.5.1 |
589 | */ |
590 | function japanese_xtra_utf7_imap_encode($ret){ |
591 | if (function_exists('mb_detect_encoding')) { |
592 | $ret = mb_convert_encoding($ret, 'UTF7-IMAP', 'EUC-JP'); |
593 | } |
594 | return $ret; |
595 | } |
a8fa8e33 |
596 | |
e0e1b169 |
597 | /** |
598 | * Japanese imap folder name decoding function |
599 | * |
600 | * converts folder name from utf7-imap to euc-jp. |
601 | * @param string $ret folder name in utf7-imap |
602 | * @return string converted folder name |
603 | * @since 1.5.1 |
604 | */ |
605 | function japanese_xtra_utf7_imap_decode($ret) { |
606 | if (function_exists('mb_detect_encoding')) { |
607 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'UTF7-IMAP'); |
608 | } |
609 | return $ret; |
610 | } |
a8fa8e33 |
611 | |
e0e1b169 |
612 | /** |
613 | * Japanese string trimming function |
614 | * |
615 | * trims string to defined number of symbols |
616 | * @param string $ret string |
617 | * @param integer $width number of symbols |
618 | * @return string trimmed string |
619 | * @since 1.5.1 |
620 | */ |
621 | function japanese_xtra_strimwidth($ret,$width) { |
622 | if (function_exists('mb_detect_encoding')) { |
623 | $ret = mb_strimwidth($ret, 0, $width, '...'); |
624 | } |
625 | return $ret; |
626 | } |
a8fa8e33 |
627 | |
e0e1b169 |
628 | /******************************** |
629 | * Korean charset extra functions |
630 | ********************************/ |
a8fa8e33 |
631 | |
e0e1b169 |
632 | /** |
633 | * Korean downloaded filename processing functions |
634 | * |
635 | * @param string default return value |
636 | * @return string |
81be3f39 |
637 | * @since 1.5.1 |
e0e1b169 |
638 | */ |
639 | function korean_xtra_downloadfilename($ret) { |
640 | $ret = str_replace("\x0D\x0A", '', $ret); /* Hanmail's CR/LF Clear */ |
641 | for ($i=0;$i<strlen($ret);$i++) { |
642 | if ($ret[$i] >= "\xA1" && $ret[$i] <= "\xFE") { /* 0xA1 - 0XFE are Valid */ |
643 | $i++; |
644 | continue; |
645 | } else if (($ret[$i] >= 'a' && $ret[$i] <= 'z') || /* From Original ereg_replace in download.php */ |
646 | ($ret[$i] >= 'A' && $ret[$i] <= 'Z') || |
647 | ($ret[$i] == '.') || ($ret[$i] == '-')) { |
648 | continue; |
649 | } else { |
650 | $ret[$i] = '_'; |
651 | } |
652 | } |
653 | return $ret; |
654 | } |
a8fa8e33 |
655 | |
e0e1b169 |
656 | /** |
657 | * Replaces non-braking spaces inserted by some browsers with regular space |
658 | * |
659 | * This function can be used to replace non-braking space symbols |
660 | * that are inserted in forms by some browsers instead of normal |
661 | * space symbol. |
662 | * |
663 | * @param string $string Text that needs to be cleaned |
664 | * @param string $charset Charset used in text |
665 | * @return string Cleaned text |
666 | */ |
667 | function cleanup_nbsp($string,$charset) { |
a8fa8e33 |
668 | |
e0e1b169 |
669 | // reduce number of case statements |
670 | if (stristr('iso-8859-',substr($charset,0,9))){ |
671 | $output_charset="iso-8859-x"; |
672 | } |
673 | if (stristr('windows-125',substr($charset,0,11))){ |
674 | $output_charset="cp125x"; |
675 | } |
676 | if (stristr('koi8',substr($charset,0,4))){ |
677 | $output_charset="koi8-x"; |
678 | } |
679 | if (! isset($output_charset)){ |
680 | $output_charset=strtolower($charset); |
681 | } |
a8fa8e33 |
682 | |
e0e1b169 |
683 | // where is non-braking space symbol |
684 | switch($output_charset): |
685 | case "iso-8859-x": |
686 | case "cp125x": |
687 | case "iso-2022-jp": |
688 | $nbsp="\xA0"; |
689 | break; |
690 | case "koi8-x": |
691 | $nbsp="\x9A"; |
692 | break; |
693 | case "utf-8": |
694 | $nbsp="\xC2\xA0"; |
695 | break; |
696 | default: |
697 | // don't change string if charset is unmatched |
698 | return $string; |
699 | endswitch; |
a8fa8e33 |
700 | |
e0e1b169 |
701 | // return space instead of non-braking space. |
702 | return str_replace($nbsp,' ',$string); |
703 | } |
a8fa8e33 |
704 | |
e0e1b169 |
705 | /** |
706 | * Function informs if it is safe to convert given charset to the one that is used by user. |
707 | * |
708 | * It is safe to use conversion only if user uses utf-8 encoding and when |
709 | * converted charset is similar to the one that is used by user. |
710 | * |
711 | * @param string $input_charset Charset of text that needs to be converted |
712 | * @return bool is it possible to convert to user's charset |
713 | */ |
714 | function is_conversion_safe($input_charset) { |
715 | global $languages, $sm_notAlias, $default_charset, $lossy_encoding; |
a8fa8e33 |
716 | |
e0e1b169 |
717 | if (isset($lossy_encoding) && $lossy_encoding ) |
718 | return true; |
a8fa8e33 |
719 | |
e0e1b169 |
720 | // convert to lower case |
721 | $input_charset = strtolower($input_charset); |
a8fa8e33 |
722 | |
e0e1b169 |
723 | // Is user's locale Unicode based ? |
724 | if ( $default_charset == "utf-8" ) { |
725 | return true; |
726 | } |
a8fa8e33 |
727 | |
e0e1b169 |
728 | // Charsets that are similar |
729 | switch ($default_charset): |
730 | case "windows-1251": |
731 | if ( $input_charset == "iso-8859-5" || |
732 | $input_charset == "koi8-r" || |
733 | $input_charset == "koi8-u" ) { |
734 | return true; |
735 | } else { |
736 | return false; |
737 | } |
738 | case "windows-1257": |
739 | if ( $input_charset == "iso-8859-13" || |
740 | $input_charset == "iso-8859-4" ) { |
741 | return true; |
742 | } else { |
743 | return false; |
744 | } |
745 | case "iso-8859-4": |
746 | if ( $input_charset == "iso-8859-13" || |
747 | $input_charset == "windows-1257" ) { |
748 | return true; |
749 | } else { |
750 | return false; |
751 | } |
752 | case "iso-8859-5": |
753 | if ( $input_charset == "windows-1251" || |
754 | $input_charset == "koi8-r" || |
755 | $input_charset == "koi8-u" ) { |
756 | return true; |
757 | } else { |
758 | return false; |
759 | } |
760 | case "iso-8859-13": |
761 | if ( $input_charset == "iso-8859-4" || |
762 | $input_charset == "windows-1257" ) { |
763 | return true; |
764 | } else { |
765 | return false; |
766 | } |
767 | case "koi8-r": |
768 | if ( $input_charset == "windows-1251" || |
769 | $input_charset == "iso-8859-5" || |
770 | $input_charset == "koi8-u" ) { |
771 | return true; |
772 | } else { |
773 | return false; |
774 | } |
775 | case "koi8-u": |
776 | if ( $input_charset == "windows-1251" || |
777 | $input_charset == "iso-8859-5" || |
778 | $input_charset == "koi8-r" ) { |
779 | return true; |
780 | } else { |
781 | return false; |
782 | } |
783 | default: |
784 | return false; |
785 | endswitch; |
786 | } |
551a09c7 |
787 | |
a8fa8e33 |
788 | |
e0e1b169 |
789 | /* ------------------------------ main --------------------------- */ |
a8fa8e33 |
790 | |
e0e1b169 |
791 | global $squirrelmail_language, $languages, $use_gettext; |
060c9483 |
792 | |
e0e1b169 |
793 | if (! isset($squirrelmail_language)) { |
794 | $squirrelmail_language = ''; |
795 | } |
c30be3cf |
796 | |
e0e1b169 |
797 | /** |
798 | * Array specifies the available translations. |
799 | * |
800 | * Structure of array: |
801 | * $languages['language']['variable'] = 'value' |
802 | * |
803 | * Possible 'variable' names: |
804 | * NAME - Translation name in English |
805 | * CHARSET - Encoding used by translation |
806 | * ALIAS - used when 'language' is only short name and 'value' should provide long language name |
807 | * ALTNAME - Native translation name. Any 8bit symbols must be html encoded. |
808 | * LOCALE - Full locale name (in xx_XX.charset format) |
809 | * DIR - Text direction. Used to define Right-to-Left languages. Possible values 'rtl' or 'ltr'. If undefined - defaults to 'ltr' |
810 | * XTRA_CODE - translation uses special functions. See doc/i18n.txt |
811 | * |
812 | * Each 'language' definition requires NAME+CHARSET or ALIAS variables. |
813 | * |
814 | * @name $languages |
815 | * @global array $languages |
816 | */ |
817 | $languages['bg_BG']['NAME'] = 'Bulgarian'; |
818 | $languages['bg_BG']['ALTNAME'] = 'Български'; |
819 | $languages['bg_BG']['CHARSET'] = 'windows-1251'; |
820 | $languages['bg_BG']['LOCALE'] = 'bg_BG.CP1251'; |
821 | $languages['bg']['ALIAS'] = 'bg_BG'; |
c30be3cf |
822 | |
e0e1b169 |
823 | $languages['bn_IN']['NAME'] = 'Bengali'; |
824 | $languages['bn_IN']['CHARSET'] = 'utf-8'; |
825 | $languages['bn_IN']['LOCALE'] = 'bn_IN.UTF-8'; |
2729f5a2 |
826 | $languages['bn_BD']['ALIAS'] = 'bn_IN'; |
e0e1b169 |
827 | $languages['bn']['ALIAS'] = 'bn_IN'; |
a8fa8e33 |
828 | |
e0e1b169 |
829 | $languages['ca_ES']['NAME'] = 'Catalan'; |
830 | $languages['ca_ES']['CHARSET'] = 'iso-8859-1'; |
831 | $languages['ca_ES']['LOCALE'] = 'ca_ES.ISO8859-1'; |
832 | $languages['ca']['ALIAS'] = 'ca_ES'; |
a8fa8e33 |
833 | |
e0e1b169 |
834 | $languages['cs_CZ']['NAME'] = 'Czech'; |
835 | $languages['cs_CZ']['ALTNAME'] = 'Čeština'; |
836 | $languages['cs_CZ']['CHARSET'] = 'iso-8859-2'; |
837 | $languages['cs_CZ']['LOCALE'] = 'cs_CZ.ISO8859-2'; |
838 | $languages['cs']['ALIAS'] = 'cs_CZ'; |
4417eead |
839 | |
e0e1b169 |
840 | $languages['cy_GB']['NAME'] = 'Welsh'; |
841 | $languages['cy_GB']['ALTNAME'] = 'Cymraeg'; |
842 | $languages['cy_GB']['CHARSET'] = 'iso-8859-1'; |
843 | $languages['cy_GB']['LOCALE'] = 'cy_GB.ISO8859-1'; |
844 | $languages['cy']['ALIAS'] = 'cy_GB'; |
d3b57948 |
845 | |
e0e1b169 |
846 | // Danish locale is da_DK. |
847 | $languages['da_DK']['NAME'] = 'Danish'; |
848 | $languages['da_DK']['ALTNAME'] = 'Dansk'; |
849 | $languages['da_DK']['CHARSET'] = 'iso-8859-1'; |
850 | $languages['da_DK']['LOCALE'] = 'da_DK.ISO8859-1'; |
851 | $languages['da']['ALIAS'] = 'da_DK'; |
2ba590f9 |
852 | |
e0e1b169 |
853 | $languages['de_DE']['NAME'] = 'German'; |
854 | $languages['de_DE']['ALTNAME'] = 'Deutsch'; |
855 | $languages['de_DE']['CHARSET'] = 'iso-8859-1'; |
856 | $languages['de_DE']['LOCALE'] = 'de_DE.ISO8859-1'; |
857 | $languages['de']['ALIAS'] = 'de_DE'; |
a2a7852b |
858 | |
e0e1b169 |
859 | $languages['el_GR']['NAME'] = 'Greek'; |
860 | $languages['el_GR']['ALTNAME'] = 'Ελληνικά'; |
861 | $languages['el_GR']['CHARSET'] = 'iso-8859-7'; |
862 | $languages['el_GR']['LOCALE'] = 'el_GR.ISO8859-7'; |
863 | $languages['el']['ALIAS'] = 'el_GR'; |
3b84e1b1 |
864 | |
e0e1b169 |
865 | $languages['en_GB']['NAME'] = 'British'; |
866 | $languages['en_GB']['CHARSET'] = 'iso-8859-15'; |
867 | $languages['en_GB']['LOCALE'] = 'en_GB.ISO8859-15'; |
3b84e1b1 |
868 | |
e0e1b169 |
869 | $languages['en_US']['NAME'] = 'English'; |
870 | $languages['en_US']['CHARSET'] = 'iso-8859-1'; |
871 | $languages['en_US']['LOCALE'] = 'en_US.ISO8859-1'; |
872 | $languages['en']['ALIAS'] = 'en_US'; |
a2a7852b |
873 | |
e0e1b169 |
874 | $languages['es_ES']['NAME'] = 'Spanish'; |
875 | $languages['es_ES']['ALTNAME'] = 'Español'; |
876 | $languages['es_ES']['CHARSET'] = 'iso-8859-1'; |
877 | $languages['es_ES']['LOCALE'] = 'es_ES.ISO8859-1'; |
878 | $languages['es']['ALIAS'] = 'es_ES'; |
1d33e35e |
879 | |
e0e1b169 |
880 | $languages['et_EE']['NAME'] = 'Estonian'; |
881 | $languages['et_EE']['CHARSET'] = 'iso-8859-15'; |
882 | $languages['et_EE']['LOCALE'] = 'et_EE.ISO8859-15'; |
883 | $languages['et']['ALIAS'] = 'et_EE'; |
62f7daa5 |
884 | |
e0e1b169 |
885 | $languages['eu_ES']['NAME'] = 'Basque'; |
886 | $languages['eu_ES']['CHARSET'] = 'iso-8859-1'; |
887 | $languages['eu_ES']['LOCALE'] = 'eu_ES.ISO8859-1'; |
888 | $languages['eu']['ALIAS'] = 'eu_ES'; |
1d33e35e |
889 | |
e0e1b169 |
890 | $languages['fo_FO']['NAME'] = 'Faroese'; |
891 | $languages['fo_FO']['CHARSET'] = 'iso-8859-1'; |
892 | $languages['fo_FO']['LOCALE'] = 'fo_FO.ISO8859-1'; |
893 | $languages['fo']['ALIAS'] = 'fo_FO'; |
1d33e35e |
894 | |
e0e1b169 |
895 | $languages['fi_FI']['NAME'] = 'Finnish'; |
896 | $languages['fi_FI']['ALTNAME'] = 'Suomi'; |
897 | $languages['fi_FI']['CHARSET'] = 'iso-8859-1'; |
898 | $languages['fi_FI']['LOCALE'] = 'fi_FI.ISO8859-1'; |
899 | $languages['fi']['ALIAS'] = 'fi_FI'; |
1bb86586 |
900 | |
e0e1b169 |
901 | $languages['fr_FR']['NAME'] = 'French'; |
902 | $languages['fr_FR']['ALTNAME'] = 'Français'; |
903 | $languages['fr_FR']['CHARSET'] = 'iso-8859-1'; |
904 | $languages['fr_FR']['LOCALE'] = 'fr_FR.ISO8859-1'; |
905 | $languages['fr']['ALIAS'] = 'fr_FR'; |
1bb86586 |
906 | |
e0e1b169 |
907 | $languages['hr_HR']['NAME'] = 'Croatian'; |
908 | $languages['hr_HR']['CHARSET'] = 'iso-8859-2'; |
909 | $languages['hr_HR']['LOCALE'] = 'hr_HR.ISO8859-2'; |
910 | $languages['hr']['ALIAS'] = 'hr_HR'; |
62f7daa5 |
911 | |
e0e1b169 |
912 | $languages['hu_HU']['NAME'] = 'Hungarian'; |
913 | $languages['hu_HU']['ALTNAME'] = 'Magyar'; |
914 | $languages['hu_HU']['CHARSET'] = 'iso-8859-2'; |
915 | $languages['hu_HU']['LOCALE'] = 'hu_HU.ISO8859-2'; |
916 | $languages['hu']['ALIAS'] = 'hu_HU'; |
1bb86586 |
917 | |
e0e1b169 |
918 | $languages['id_ID']['NAME'] = 'Indonesian'; |
919 | $languages['id_ID']['ALTNAME'] = 'Bahasa Indonesia'; |
920 | $languages['id_ID']['CHARSET'] = 'iso-8859-1'; |
921 | $languages['id_ID']['LOCALE'] = 'id_ID.ISO8859-1'; |
922 | $languages['id']['ALIAS'] = 'id_ID'; |
1bb86586 |
923 | |
e0e1b169 |
924 | $languages['is_IS']['NAME'] = 'Icelandic'; |
925 | $languages['is_IS']['ALTNAME'] = 'Íslenska'; |
926 | $languages['is_IS']['CHARSET'] = 'iso-8859-1'; |
927 | $languages['is_IS']['LOCALE'] = 'is_IS.ISO8859-1'; |
928 | $languages['is']['ALIAS'] = 'is_IS'; |
1bb86586 |
929 | |
e0e1b169 |
930 | $languages['it_IT']['NAME'] = 'Italian'; |
931 | $languages['it_IT']['CHARSET'] = 'iso-8859-1'; |
932 | $languages['it_IT']['LOCALE'] = 'it_IT.ISO8859-1'; |
933 | $languages['it']['ALIAS'] = 'it_IT'; |
1bb86586 |
934 | |
e0e1b169 |
935 | $languages['ja_JP']['NAME'] = 'Japanese'; |
936 | $languages['ja_JP']['ALTNAME'] = '日本語'; |
937 | $languages['ja_JP']['CHARSET'] = 'iso-2022-jp'; |
938 | $languages['ja_JP']['LOCALE'] = 'ja_JP.EUC-JP'; |
939 | $languages['ja_JP']['XTRA_CODE'] = 'japanese_xtra'; |
940 | $languages['ja']['ALIAS'] = 'ja_JP'; |
62f7daa5 |
941 | |
e0e1b169 |
942 | $languages['ko_KR']['NAME'] = 'Korean'; |
943 | $languages['ko_KR']['CHARSET'] = 'euc-KR'; |
944 | $languages['ko_KR']['LOCALE'] = 'ko_KR.EUC-KR'; |
945 | $languages['ko_KR']['XTRA_CODE'] = 'korean_xtra'; |
946 | $languages['ko']['ALIAS'] = 'ko_KR'; |
1bb86586 |
947 | |
e0e1b169 |
948 | $languages['lt_LT']['NAME'] = 'Lithuanian'; |
949 | $languages['lt_LT']['ALTNAME'] = 'Lietuvių'; |
950 | $languages['lt_LT']['CHARSET'] = 'utf-8'; |
951 | $languages['lt_LT']['LOCALE'] = 'lt_LT.UTF-8'; |
952 | $languages['lt']['ALIAS'] = 'lt_LT'; |
62f7daa5 |
953 | |
e0e1b169 |
954 | $languages['nl_NL']['NAME'] = 'Dutch'; |
955 | $languages['nl_NL']['ALTNAME'] = 'Nederlands'; |
956 | $languages['nl_NL']['CHARSET'] = 'iso-8859-1'; |
957 | $languages['nl_NL']['LOCALE'] = 'nl_NL.ISO8859-1'; |
958 | $languages['nl']['ALIAS'] = 'nl_NL'; |
62f7daa5 |
959 | |
e0e1b169 |
960 | $languages['ms_MY']['NAME'] = 'Malay'; |
961 | $languages['ms_MY']['ALTNAME'] = 'Bahasa Melayu'; |
962 | $languages['ms_MY']['CHARSET'] = 'iso-8859-1'; |
963 | $languages['ms_MY']['LOCALE'] = 'ms_MY.ISO8859-1'; |
964 | $languages['my']['ALIAS'] = 'ms_MY'; |
62f7daa5 |
965 | |
e0e1b169 |
966 | $languages['nb_NO']['NAME'] = 'Norwegian (Bokmål)'; |
967 | $languages['nb_NO']['ALTNAME'] = 'Norsk (Bokmål)'; |
968 | $languages['nb_NO']['CHARSET'] = 'iso-8859-1'; |
969 | $languages['nb_NO']['LOCALE'] = 'nb_NO.ISO8859-1'; |
970 | $languages['nb']['ALIAS'] = 'nb_NO'; |
1bb86586 |
971 | |
e0e1b169 |
972 | $languages['nn_NO']['NAME'] = 'Norwegian (Nynorsk)'; |
973 | $languages['nn_NO']['ALTNAME'] = 'Norsk (Nynorsk)'; |
974 | $languages['nn_NO']['CHARSET'] = 'iso-8859-1'; |
975 | $languages['nn_NO']['LOCALE'] = 'nn_NO.ISO8859-1'; |
1bb86586 |
976 | |
e0e1b169 |
977 | $languages['pl_PL']['NAME'] = 'Polish'; |
978 | $languages['pl_PL']['ALTNAME'] = 'Polski'; |
979 | $languages['pl_PL']['CHARSET'] = 'iso-8859-2'; |
980 | $languages['pl_PL']['LOCALE'] = 'pl_PL.ISO8859-2'; |
981 | $languages['pl']['ALIAS'] = 'pl_PL'; |
1bb86586 |
982 | |
e0e1b169 |
983 | $languages['pt_PT']['NAME'] = 'Portuguese (Portugal)'; |
984 | $languages['pt_PT']['CHARSET'] = 'iso-8859-1'; |
985 | $languages['pt_PT']['LOCALE'] = 'pt_PT.ISO8859-1'; |
986 | $languages['pt']['ALIAS'] = 'pt_PT'; |
1bb86586 |
987 | |
e0e1b169 |
988 | $languages['pt_BR']['NAME'] = 'Portuguese (Brazil)'; |
989 | $languages['pt_BR']['ALTNAME'] = 'Português do Brasil'; |
990 | $languages['pt_BR']['CHARSET'] = 'iso-8859-1'; |
991 | $languages['pt_BR']['LOCALE'] = 'pt_BR.ISO8859-1'; |
1bb86586 |
992 | |
e0e1b169 |
993 | $languages['ro_RO']['NAME'] = 'Romanian'; |
994 | $languages['ro_RO']['ALTNAME'] = 'Română'; |
995 | $languages['ro_RO']['CHARSET'] = 'iso-8859-2'; |
996 | $languages['ro_RO']['LOCALE'] = 'ro_RO.ISO8859-2'; |
997 | $languages['ro']['ALIAS'] = 'ro_RO'; |
1d33e35e |
998 | |
e0e1b169 |
999 | $languages['ru_RU']['NAME'] = 'Russian'; |
1000 | $languages['ru_RU']['ALTNAME'] = 'Русский'; |
1001 | $languages['ru_RU']['CHARSET'] = 'utf-8'; |
1002 | $languages['ru_RU']['LOCALE'] = 'ru_RU.UTF-8'; |
1003 | $languages['ru']['ALIAS'] = 'ru_RU'; |
9af9c0a2 |
1004 | |
e0e1b169 |
1005 | $languages['sk_SK']['NAME'] = 'Slovak'; |
1006 | $languages['sk_SK']['CHARSET'] = 'iso-8859-2'; |
1007 | $languages['sk_SK']['LOCALE'] = 'sk_SK.ISO8859-2'; |
1008 | $languages['sk']['ALIAS'] = 'sk_SK'; |
9af9c0a2 |
1009 | |
e0e1b169 |
1010 | $languages['sl_SI']['NAME'] = 'Slovenian'; |
1011 | $languages['sl_SI']['ALTNAME'] = 'Slovenščina'; |
1012 | $languages['sl_SI']['CHARSET'] = 'iso-8859-2'; |
1013 | $languages['sl_SI']['LOCALE'] = 'sl_SI.ISO8859-2'; |
1014 | $languages['sl']['ALIAS'] = 'sl_SI'; |
9af9c0a2 |
1015 | |
e0e1b169 |
1016 | $languages['sr_YU']['NAME'] = 'Serbian'; |
1017 | $languages['sr_YU']['ALTNAME'] = 'Srpski'; |
1018 | $languages['sr_YU']['CHARSET'] = 'iso-8859-2'; |
1019 | $languages['sr_YU']['LOCALE'] = 'sr_YU.ISO8859-2'; |
1020 | $languages['sr']['ALIAS'] = 'sr_YU'; |
4e519821 |
1021 | |
e0e1b169 |
1022 | $languages['sv_SE']['NAME'] = 'Swedish'; |
1023 | $languages['sv_SE']['ALTNAME'] = 'Svenska'; |
1024 | $languages['sv_SE']['CHARSET'] = 'iso-8859-1'; |
1025 | $languages['sv_SE']['LOCALE'] = 'sv_SE.ISO8859-1'; |
1026 | $languages['sv']['ALIAS'] = 'sv_SE'; |
33991968 |
1027 | |
e0e1b169 |
1028 | $languages['th_TH']['NAME'] = 'Thai'; |
1029 | $languages['th_TH']['CHARSET'] = 'tis-620'; |
1030 | $languages['th_TH']['LOCALE'] = 'th_TH.TIS-620'; |
1031 | $languages['th']['ALIAS'] = 'th_TH'; |
4e519821 |
1032 | |
e0e1b169 |
1033 | $languages['tl_PH']['NAME'] = 'Tagalog'; |
1034 | $languages['tl_PH']['CHARSET'] = 'iso-8859-1'; |
1035 | $languages['tl_PH']['LOCALE'] = 'tl_PH.ISO8859-1'; |
1036 | $languages['tl']['ALIAS'] = 'tl_PH'; |
4e519821 |
1037 | |
e0e1b169 |
1038 | $languages['tr_TR']['NAME'] = 'Turkish'; |
1039 | $languages['tr_TR']['CHARSET'] = 'iso-8859-9'; |
1040 | $languages['tr_TR']['LOCALE'] = 'tr_TR.ISO8859-9'; |
1041 | $languages['tr']['ALIAS'] = 'tr_TR'; |
4e519821 |
1042 | |
e0e1b169 |
1043 | $languages['zh_TW']['NAME'] = 'Chinese Trad'; |
1044 | $languages['zh_TW']['CHARSET'] = 'big5'; |
1045 | $languages['zh_TW']['LOCALE'] = 'zh_TW.BIG5'; |
1046 | $languages['tw']['ALIAS'] = 'zh_TW'; |
1047 | |
1048 | $languages['zh_CN']['NAME'] = 'Chinese Simp'; |
1049 | $languages['zh_CN']['CHARSET'] = 'gb2312'; |
1050 | $languages['zh_CN']['LOCALE'] = 'zh_CN.GB2312'; |
1051 | $languages['cn']['ALIAS'] = 'zh_CN'; |
1052 | |
1053 | $languages['uk_UA']['NAME'] = 'Ukrainian'; |
1054 | $languages['uk_UA']['CHARSET'] = 'koi8-u'; |
1055 | $languages['uk_UA']['LOCALE'] = 'uk_UA.KOI8-U'; |
1056 | $languages['uk']['ALIAS'] = 'uk_UA'; |
1057 | |
1058 | $languages['ru_UA']['NAME'] = 'Russian (Ukrainian)'; |
1059 | $languages['ru_UA']['CHARSET'] = 'koi8-r'; |
1060 | $languages['ru_UA']['LOCALE'] = 'ru_UA.KOI8-R'; |
1061 | |
1062 | /* |
1063 | $languages['vi_VN']['NAME'] = 'Vietnamese'; |
1064 | $languages['vi_VN']['CHARSET'] = 'utf-8'; |
1065 | $languages['vi']['ALIAS'] = 'vi_VN'; |
1066 | */ |
1067 | |
1068 | // Right to left languages |
1069 | $languages['ar']['NAME'] = 'Arabic'; |
1070 | $languages['ar']['CHARSET'] = 'windows-1256'; |
1071 | $languages['ar']['DIR'] = 'rtl'; |
1072 | |
1073 | $languages['fa_IR']['NAME'] = 'Farsi'; |
1074 | $languages['fa_IR']['CHARSET'] = 'utf-8'; |
1075 | $languages['fa_IR']['DIR'] = 'rtl'; |
1076 | $languages['fa_IR']['LOCALE'] = 'fa_IR.UTF-8'; |
1077 | $languages['fa']['ALIAS'] = 'fa_IR'; |
1078 | |
1079 | $languages['he_IL']['NAME'] = 'Hebrew'; |
1080 | $languages['he_IL']['CHARSET'] = 'windows-1255'; |
1081 | $languages['he_IL']['LOCALE'] = 'he_IL.CP1255'; |
1082 | $languages['he_IL']['DIR'] = 'rtl'; |
1083 | $languages['he']['ALIAS'] = 'he_IL'; |
1084 | |
1085 | $languages['ug']['NAME'] = 'Uighur'; |
1086 | $languages['ug']['CHARSET'] = 'utf-8'; |
1087 | $languages['ug']['DIR'] = 'rtl'; |
1088 | |
1089 | /* Detect whether gettext is installed. */ |
1090 | $gettext_flags = 0; |
1091 | if (function_exists('_')) { |
1092 | $gettext_flags += 1; |
1093 | } |
1094 | if (function_exists('bindtextdomain')) { |
1095 | $gettext_flags += 2; |
1096 | } |
1097 | if (function_exists('textdomain')) { |
1098 | $gettext_flags += 4; |
1099 | } |
1100 | if (function_exists('ngettext')) { |
1101 | $gettext_flags += 8; |
1102 | } |
1103 | |
1104 | /* If gettext is fully loaded, cool */ |
1105 | if ($gettext_flags == 15) { |
1106 | $use_gettext = true; |
1107 | } |
1108 | |
1109 | /* If ngettext support is missing, load it */ |
1110 | elseif ($gettext_flags == 7) { |
1111 | $use_gettext = true; |
1112 | // load internal ngettext functions |
1113 | include_once(SM_PATH . 'class/l10n.class.php'); |
1114 | include_once(SM_PATH . 'functions/ngettext.php'); |
1115 | } |
1116 | |
1117 | /* If we can fake gettext, try that */ |
1118 | elseif ($gettext_flags == 0) { |
1119 | $use_gettext = true; |
1120 | include_once(SM_PATH . 'functions/gettext.php'); |
1121 | } else { |
1122 | /* Uh-ho. A weird install */ |
1123 | if (! $gettext_flags & 1) { |
1124 | /** |
1125 | * Function is used as replacement in broken installs |
1126 | * @ignore |
1127 | */ |
1128 | function _($str) { |
1129 | return $str; |
1130 | } |
1131 | } |
1132 | if (! $gettext_flags & 2) { |
1133 | /** |
1134 | * Function is used as replacement in broken installs |
1135 | * @ignore |
1136 | */ |
1137 | function bindtextdomain() { |
1138 | return; |
1139 | } |
1140 | } |
1141 | if (! $gettext_flags & 4) { |
1142 | /** |
1143 | * Function is used as replacemet in broken installs |
1144 | * @ignore |
1145 | */ |
1146 | function textdomain() { |
1147 | return; |
1148 | } |
1149 | } |
1150 | if (! $gettext_flags & 8) { |
1151 | /** |
1152 | * Function is used as replacemet in broken installs |
1153 | * @ignore |
1154 | */ |
1155 | function ngettext($str,$str2,$number) { |
1156 | if ($number>1) { |
1157 | return $str2; |
1158 | } else { |
1159 | return $str; |
1160 | } |
1161 | } |
1162 | } |
4e519821 |
1163 | } |
51468260 |
1164 | ?> |