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" ); |
475df436 |
295 | if ($sm_notAlias=='tr_TR') putenv( "LC_CTYPE=C" ); |
a2a7852b |
296 | } |
03db90bc |
297 | setlocale(LC_ALL, $longlocale); |
475df436 |
298 | if ($sm_notAlias=='tr_TR') setlocale(LC_CTYPE,'C'); |
03db90bc |
299 | |
300 | // Set text direction/alignment variables |
62f7daa5 |
301 | if (isset($languages[$sm_notAlias]['DIR']) && |
03db90bc |
302 | $languages[$sm_notAlias]['DIR'] == 'rtl') { |
3b84e1b1 |
303 | /** |
304 | * Text direction |
305 | * @global string $text_direction |
306 | */ |
307 | $text_direction='rtl'; |
308 | /** |
309 | * Left alignment |
310 | * @global string $left_align |
311 | */ |
312 | $left_align='right'; |
313 | /** |
314 | * Right alignment |
315 | * @global string $right_align |
316 | */ |
317 | $right_align='left'; |
03db90bc |
318 | } else { |
3b84e1b1 |
319 | $text_direction='ltr'; |
320 | $left_align='left'; |
321 | $right_align='right'; |
03db90bc |
322 | } |
323 | |
324 | $squirrelmail_language = $sm_notAlias; |
a5970d71 |
325 | if ($squirrelmail_language == 'ja_JP') { |
b05c8961 |
326 | header ('Content-Type: text/html; charset=EUC-JP'); |
327 | if (!function_exists('mb_internal_encoding')) { |
3b84e1b1 |
328 | // Error messages can't be displayed here |
329 | $error = 1; |
330 | // Revert to English if possible. |
331 | if (function_exists('setPref') && $username!='' && $data_dir!="") { |
332 | setPref($data_dir, $username, 'language', "en_US"); |
333 | $error = 2; |
334 | } |
335 | // stop further execution in order not to get php errors on mb_internal_encoding(). |
336 | return $error; |
e842b215 |
337 | } |
338 | if (function_exists('mb_language')) { |
339 | mb_language('Japanese'); |
b05c8961 |
340 | } |
341 | mb_internal_encoding('EUC-JP'); |
342 | mb_http_output('pass'); |
fe48c808 |
343 | } elseif ($squirrelmail_language == 'en_US') { |
344 | header( 'Content-Type: text/html; charset=' . $default_charset ); |
b05c8961 |
345 | } else { |
fe48c808 |
346 | header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] ); |
347 | } |
a2a7852b |
348 | } |
51468260 |
349 | return 0; |
b05c8961 |
350 | } |
a2a7852b |
351 | |
51468260 |
352 | /** |
353 | * Sets default_charset variable according to the one that is used by user's translations. |
354 | * |
355 | * Function changes global $default_charset variable in order to be sure, that it |
356 | * contains charset used by user's translation. Sanity of $squirrelmail_default_language |
357 | * and $default_charset combination provided in SquirrelMail config is also tested. |
358 | * |
359 | * There can be a $default_charset setting in the |
360 | * config.php file, but the user may have a different language |
361 | * selected for a user interface. This function checks the |
362 | * language selected by the user and tags the outgoing messages |
363 | * with the appropriate charset corresponding to the language |
364 | * selection. This is "more right" (tm), than just stamping the |
365 | * message blindly with the system-wide $default_charset. |
366 | */ |
a2a7852b |
367 | function set_my_charset(){ |
94965562 |
368 | global $data_dir, $username, $default_charset, $languages, $squirrelmail_default_language; |
88cb1b4d |
369 | |
a2a7852b |
370 | $my_language = getPref($data_dir, $username, 'language'); |
5c920668 |
371 | if (!$my_language) { |
94965562 |
372 | $my_language = $squirrelmail_default_language ; |
5c920668 |
373 | } |
3ec81e63 |
374 | // Catch removed translation |
375 | if (!isset($languages[$my_language])) { |
3b84e1b1 |
376 | $my_language="en_US"; |
3ec81e63 |
377 | } |
a2a7852b |
378 | while (isset($languages[$my_language]['ALIAS'])) { |
f7e8861e |
379 | $my_language = $languages[$my_language]['ALIAS']; |
a2a7852b |
380 | } |
5c920668 |
381 | $my_charset = $languages[$my_language]['CHARSET']; |
fe48c808 |
382 | if ($my_language!='en_US') { |
a2a7852b |
383 | $default_charset = $my_charset; |
384 | } |
385 | } |
386 | |
e0e1b169 |
387 | /************************** |
388 | * Japanese extra functions |
389 | **************************/ |
a2a7852b |
390 | |
e0e1b169 |
391 | /** |
392 | * Japanese decoding function |
393 | * |
394 | * converts string to euc-jp, if string uses JIS, EUC-JP, ShiftJIS or UTF-8 |
395 | * charset. Needs mbstring support in php. |
396 | * @param string $ret text, that has to be converted |
397 | * @return string converted string |
398 | * @since 1.5.1 |
399 | */ |
400 | function japanese_xtra_decode($ret) { |
401 | if (function_exists('mb_detect_encoding')) { |
402 | $detect_encoding = @mb_detect_encoding($ret); |
403 | if ($detect_encoding == 'JIS' || |
404 | $detect_encoding == 'EUC-JP' || |
405 | $detect_encoding == 'SJIS' || |
406 | $detect_encoding == 'UTF-8') { |
5c920668 |
407 | |
e0e1b169 |
408 | $ret = mb_convert_kana(mb_convert_encoding($ret, 'EUC-JP', 'AUTO'), "KV"); |
409 | } |
410 | } |
411 | return $ret; |
a2a7852b |
412 | } |
413 | |
51468260 |
414 | /** |
e0e1b169 |
415 | * Japanese encoding function |
51468260 |
416 | * |
e0e1b169 |
417 | * converts string to jis, if string uses JIS, EUC-JP, ShiftJIS or UTF-8 |
418 | * charset. Needs mbstring support in php. |
419 | * @param string $ret text, that has to be converted |
420 | * @return string converted text |
421 | * @since 1.5.1 |
51468260 |
422 | */ |
e0e1b169 |
423 | function japanese_xtra_encode($ret) { |
424 | if (function_exists('mb_detect_encoding')) { |
425 | $detect_encoding = @mb_detect_encoding($ret); |
426 | if ($detect_encoding == 'JIS' || |
427 | $detect_encoding == 'EUC-JP' || |
428 | $detect_encoding == 'SJIS' || |
429 | $detect_encoding == 'UTF-8') { |
a8fa8e33 |
430 | |
e0e1b169 |
431 | $ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO'); |
432 | } |
433 | } |
434 | return $ret; |
435 | } |
a8fa8e33 |
436 | |
e0e1b169 |
437 | /** |
438 | * Japanese header encoding function |
439 | * |
440 | * creates base64 encoded header in iso-2022-jp charset |
441 | * @param string $ret text, that has to be converted |
442 | * @return string mime base64 encoded string |
443 | * @since 1.5.1 |
444 | */ |
445 | function japanese_xtra_encodeheader($ret) { |
446 | if (function_exists('mb_detect_encoding')) { |
447 | $result = ''; |
448 | if (strlen($ret) > 0) { |
449 | $tmpstr = mb_substr($ret, 0, 1); |
450 | $prevcsize = strlen($tmpstr); |
451 | for ($i = 1; $i < mb_strlen($ret); $i++) { |
452 | $tmp = mb_substr($ret, $i, 1); |
453 | if (strlen($tmp) == $prevcsize) { |
454 | $tmpstr .= $tmp; |
455 | } else { |
456 | if ($prevcsize == 1) { |
457 | $result .= $tmpstr; |
458 | } else { |
459 | $result .= str_replace(' ', '', |
460 | mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); |
461 | } |
462 | $tmpstr = $tmp; |
463 | $prevcsize = strlen($tmp); |
464 | } |
465 | } |
466 | if (strlen($tmpstr)) { |
467 | if (strlen(mb_substr($tmpstr, 0, 1)) == 1) |
468 | $result .= $tmpstr; |
469 | else |
470 | $result .= str_replace(' ', '', |
471 | mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); |
472 | } |
473 | } |
474 | $ret = $result; |
475 | } |
476 | return $ret; |
477 | } |
a8fa8e33 |
478 | |
e0e1b169 |
479 | /** |
480 | * Japanese header decoding function |
481 | * |
482 | * return human readable string from mime header. string is returned in euc-jp |
483 | * charset. |
484 | * @param string $ret header string |
485 | * @return string decoded header string |
486 | * @since 1.5.1 |
487 | */ |
488 | function japanese_xtra_decodeheader($ret) { |
489 | if (function_exists('mb_detect_encoding')) { |
490 | $ret = str_replace("\t", "", $ret); |
491 | if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', $ret)) |
492 | $ret = @mb_decode_mimeheader($ret); |
493 | $ret = @mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
494 | } |
495 | return $ret; |
496 | } |
a8fa8e33 |
497 | |
e0e1b169 |
498 | /** |
499 | * Japanese downloaded filename processing function |
500 | * |
501 | * Returns shift-jis or euc-jp encoded file name |
502 | * @param string $ret string |
503 | * @param string $useragent browser |
504 | * @return string converted string |
505 | * @since 1.5.1 |
506 | */ |
507 | function japanese_xtra_downloadfilename($ret,$useragent) { |
508 | if (function_exists('mb_detect_encoding')) { |
509 | if (strstr($useragent, 'Windows') !== false || |
510 | strstr($useragent, 'Mac_') !== false) { |
511 | $ret = mb_convert_encoding($ret, 'SJIS', 'AUTO'); |
512 | } else { |
513 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
514 | } |
515 | } |
516 | return $ret; |
517 | } |
a2a7852b |
518 | |
e0e1b169 |
519 | /** |
520 | * Japanese wordwrap function |
521 | * |
522 | * wraps text at set number of symbols |
523 | * @param string $ret text |
524 | * @param integer $wrap number of symbols per line |
525 | * @return string wrapped text |
526 | * @since 1.5.1 |
527 | */ |
528 | function japanese_xtra_wordwrap($ret,$wrap) { |
529 | if (function_exists('mb_detect_encoding')) { |
530 | $no_begin = "\x21\x25\x29\x2c\x2e\x3a\x3b\x3f\x5d\x7d\xa1\xf1\xa1\xeb\xa1" . |
531 | "\xc7\xa1\xc9\xa2\xf3\xa1\xec\xa1\xed\xa1\xee\xa1\xa2\xa1\xa3\xa1\xb9" . |
532 | "\xa1\xd3\xa1\xd5\xa1\xd7\xa1\xd9\xa1\xdb\xa1\xcd\xa4\xa1\xa4\xa3\xa4" . |
533 | "\xa5\xa4\xa7\xa4\xa9\xa4\xc3\xa4\xe3\xa4\xe5\xa4\xe7\xa4\xee\xa1\xab" . |
534 | "\xa1\xac\xa1\xb5\xa1\xb6\xa5\xa1\xa5\xa3\xa5\xa5\xa5\xa7\xa5\xa9\xa5" . |
535 | "\xc3\xa5\xe3\xa5\xe5\xa5\xe7\xa5\xee\xa5\xf5\xa5\xf6\xa1\xa6\xa1\xbc" . |
536 | "\xa1\xb3\xa1\xb4\xa1\xaa\xa1\xf3\xa1\xcb\xa1\xa4\xa1\xa5\xa1\xa7\xa1" . |
537 | "\xa8\xa1\xa9\xa1\xcf\xa1\xd1"; |
538 | $no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" . |
539 | "\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef"; |
3bb3d83b |
540 | |
e0e1b169 |
541 | if (strlen($ret) >= $wrap && |
542 | substr($ret, 0, 1) != '>' && |
543 | strpos($ret, 'http://') === FALSE && |
544 | strpos($ret, 'https://') === FALSE && |
545 | strpos($ret, 'ftp://') === FALSE) { |
a2a7852b |
546 | |
e0e1b169 |
547 | $ret = mb_convert_kana($ret, "KV"); |
a8fa8e33 |
548 | |
e0e1b169 |
549 | $line_new = ''; |
550 | $ptr = 0; |
a8fa8e33 |
551 | |
e0e1b169 |
552 | while ($ptr < strlen($ret) - 1) { |
553 | $l = mb_strcut($ret, $ptr, $wrap); |
554 | $ptr += strlen($l); |
555 | $tmp = $l; |
2d268514 |
556 | |
e0e1b169 |
557 | $l = mb_strcut($ret, $ptr, 2); |
558 | while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) { |
559 | $tmp .= $l; |
560 | $ptr += strlen($l); |
561 | $l = mb_strcut($ret, $ptr, 1); |
562 | } |
563 | $line_new .= $tmp; |
564 | if ($ptr < strlen($ret) - 1) |
565 | $line_new .= "\n"; |
566 | } |
567 | $ret = $line_new; |
568 | } |
569 | } |
570 | return $ret; |
571 | } |
a8fa8e33 |
572 | |
e0e1b169 |
573 | /** |
574 | * Japanese imap folder name encoding function |
575 | * |
576 | * converts folder name from euc-jp to utf7-imap |
577 | * @param string $ret folder name |
578 | * @return string converted folder name |
579 | * @since 1.5.1 |
580 | */ |
581 | function japanese_xtra_utf7_imap_encode($ret){ |
582 | if (function_exists('mb_detect_encoding')) { |
583 | $ret = mb_convert_encoding($ret, 'UTF7-IMAP', 'EUC-JP'); |
584 | } |
585 | return $ret; |
586 | } |
a8fa8e33 |
587 | |
e0e1b169 |
588 | /** |
589 | * Japanese imap folder name decoding function |
590 | * |
591 | * converts folder name from utf7-imap to euc-jp. |
592 | * @param string $ret folder name in utf7-imap |
593 | * @return string converted folder name |
594 | * @since 1.5.1 |
595 | */ |
596 | function japanese_xtra_utf7_imap_decode($ret) { |
597 | if (function_exists('mb_detect_encoding')) { |
598 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'UTF7-IMAP'); |
599 | } |
600 | return $ret; |
601 | } |
a8fa8e33 |
602 | |
e0e1b169 |
603 | /** |
604 | * Japanese string trimming function |
605 | * |
606 | * trims string to defined number of symbols |
607 | * @param string $ret string |
608 | * @param integer $width number of symbols |
609 | * @return string trimmed string |
610 | * @since 1.5.1 |
611 | */ |
612 | function japanese_xtra_strimwidth($ret,$width) { |
613 | if (function_exists('mb_detect_encoding')) { |
614 | $ret = mb_strimwidth($ret, 0, $width, '...'); |
615 | } |
616 | return $ret; |
617 | } |
a8fa8e33 |
618 | |
e0e1b169 |
619 | /******************************** |
620 | * Korean charset extra functions |
621 | ********************************/ |
a8fa8e33 |
622 | |
e0e1b169 |
623 | /** |
624 | * Korean downloaded filename processing functions |
625 | * |
626 | * @param string default return value |
627 | * @return string |
81be3f39 |
628 | * @since 1.5.1 |
e0e1b169 |
629 | */ |
630 | function korean_xtra_downloadfilename($ret) { |
631 | $ret = str_replace("\x0D\x0A", '', $ret); /* Hanmail's CR/LF Clear */ |
632 | for ($i=0;$i<strlen($ret);$i++) { |
633 | if ($ret[$i] >= "\xA1" && $ret[$i] <= "\xFE") { /* 0xA1 - 0XFE are Valid */ |
634 | $i++; |
635 | continue; |
636 | } else if (($ret[$i] >= 'a' && $ret[$i] <= 'z') || /* From Original ereg_replace in download.php */ |
637 | ($ret[$i] >= 'A' && $ret[$i] <= 'Z') || |
638 | ($ret[$i] == '.') || ($ret[$i] == '-')) { |
639 | continue; |
640 | } else { |
641 | $ret[$i] = '_'; |
642 | } |
643 | } |
644 | return $ret; |
645 | } |
a8fa8e33 |
646 | |
e0e1b169 |
647 | /** |
648 | * Replaces non-braking spaces inserted by some browsers with regular space |
649 | * |
650 | * This function can be used to replace non-braking space symbols |
651 | * that are inserted in forms by some browsers instead of normal |
652 | * space symbol. |
653 | * |
654 | * @param string $string Text that needs to be cleaned |
655 | * @param string $charset Charset used in text |
656 | * @return string Cleaned text |
657 | */ |
658 | function cleanup_nbsp($string,$charset) { |
a8fa8e33 |
659 | |
e0e1b169 |
660 | // reduce number of case statements |
661 | if (stristr('iso-8859-',substr($charset,0,9))){ |
662 | $output_charset="iso-8859-x"; |
663 | } |
664 | if (stristr('windows-125',substr($charset,0,11))){ |
665 | $output_charset="cp125x"; |
666 | } |
667 | if (stristr('koi8',substr($charset,0,4))){ |
668 | $output_charset="koi8-x"; |
669 | } |
670 | if (! isset($output_charset)){ |
671 | $output_charset=strtolower($charset); |
672 | } |
a8fa8e33 |
673 | |
e0e1b169 |
674 | // where is non-braking space symbol |
675 | switch($output_charset): |
676 | case "iso-8859-x": |
677 | case "cp125x": |
678 | case "iso-2022-jp": |
679 | $nbsp="\xA0"; |
680 | break; |
681 | case "koi8-x": |
682 | $nbsp="\x9A"; |
683 | break; |
684 | case "utf-8": |
685 | $nbsp="\xC2\xA0"; |
686 | break; |
687 | default: |
688 | // don't change string if charset is unmatched |
689 | return $string; |
690 | endswitch; |
a8fa8e33 |
691 | |
e0e1b169 |
692 | // return space instead of non-braking space. |
693 | return str_replace($nbsp,' ',$string); |
694 | } |
a8fa8e33 |
695 | |
e0e1b169 |
696 | /** |
697 | * Function informs if it is safe to convert given charset to the one that is used by user. |
698 | * |
699 | * It is safe to use conversion only if user uses utf-8 encoding and when |
700 | * converted charset is similar to the one that is used by user. |
701 | * |
702 | * @param string $input_charset Charset of text that needs to be converted |
703 | * @return bool is it possible to convert to user's charset |
704 | */ |
705 | function is_conversion_safe($input_charset) { |
706 | global $languages, $sm_notAlias, $default_charset, $lossy_encoding; |
a8fa8e33 |
707 | |
e0e1b169 |
708 | if (isset($lossy_encoding) && $lossy_encoding ) |
709 | return true; |
a8fa8e33 |
710 | |
e0e1b169 |
711 | // convert to lower case |
712 | $input_charset = strtolower($input_charset); |
a8fa8e33 |
713 | |
e0e1b169 |
714 | // Is user's locale Unicode based ? |
715 | if ( $default_charset == "utf-8" ) { |
716 | return true; |
717 | } |
a8fa8e33 |
718 | |
e0e1b169 |
719 | // Charsets that are similar |
720 | switch ($default_charset): |
721 | case "windows-1251": |
722 | if ( $input_charset == "iso-8859-5" || |
723 | $input_charset == "koi8-r" || |
724 | $input_charset == "koi8-u" ) { |
725 | return true; |
726 | } else { |
727 | return false; |
728 | } |
729 | case "windows-1257": |
730 | if ( $input_charset == "iso-8859-13" || |
731 | $input_charset == "iso-8859-4" ) { |
732 | return true; |
733 | } else { |
734 | return false; |
735 | } |
736 | case "iso-8859-4": |
737 | if ( $input_charset == "iso-8859-13" || |
738 | $input_charset == "windows-1257" ) { |
739 | return true; |
740 | } else { |
741 | return false; |
742 | } |
743 | case "iso-8859-5": |
744 | if ( $input_charset == "windows-1251" || |
745 | $input_charset == "koi8-r" || |
746 | $input_charset == "koi8-u" ) { |
747 | return true; |
748 | } else { |
749 | return false; |
750 | } |
751 | case "iso-8859-13": |
752 | if ( $input_charset == "iso-8859-4" || |
753 | $input_charset == "windows-1257" ) { |
754 | return true; |
755 | } else { |
756 | return false; |
757 | } |
758 | case "koi8-r": |
759 | if ( $input_charset == "windows-1251" || |
760 | $input_charset == "iso-8859-5" || |
761 | $input_charset == "koi8-u" ) { |
762 | return true; |
763 | } else { |
764 | return false; |
765 | } |
766 | case "koi8-u": |
767 | if ( $input_charset == "windows-1251" || |
768 | $input_charset == "iso-8859-5" || |
769 | $input_charset == "koi8-r" ) { |
770 | return true; |
771 | } else { |
772 | return false; |
773 | } |
774 | default: |
775 | return false; |
776 | endswitch; |
777 | } |
551a09c7 |
778 | |
a8fa8e33 |
779 | |
e0e1b169 |
780 | /* ------------------------------ main --------------------------- */ |
a8fa8e33 |
781 | |
e0e1b169 |
782 | global $squirrelmail_language, $languages, $use_gettext; |
060c9483 |
783 | |
e0e1b169 |
784 | if (! isset($squirrelmail_language)) { |
785 | $squirrelmail_language = ''; |
786 | } |
c30be3cf |
787 | |
e0e1b169 |
788 | /** |
789 | * Array specifies the available translations. |
790 | * |
791 | * Structure of array: |
792 | * $languages['language']['variable'] = 'value' |
793 | * |
794 | * Possible 'variable' names: |
795 | * NAME - Translation name in English |
796 | * CHARSET - Encoding used by translation |
797 | * ALIAS - used when 'language' is only short name and 'value' should provide long language name |
798 | * ALTNAME - Native translation name. Any 8bit symbols must be html encoded. |
799 | * LOCALE - Full locale name (in xx_XX.charset format) |
800 | * DIR - Text direction. Used to define Right-to-Left languages. Possible values 'rtl' or 'ltr'. If undefined - defaults to 'ltr' |
801 | * XTRA_CODE - translation uses special functions. See doc/i18n.txt |
802 | * |
803 | * Each 'language' definition requires NAME+CHARSET or ALIAS variables. |
804 | * |
805 | * @name $languages |
806 | * @global array $languages |
807 | */ |
808 | $languages['bg_BG']['NAME'] = 'Bulgarian'; |
809 | $languages['bg_BG']['ALTNAME'] = 'Български'; |
810 | $languages['bg_BG']['CHARSET'] = 'windows-1251'; |
811 | $languages['bg_BG']['LOCALE'] = 'bg_BG.CP1251'; |
812 | $languages['bg']['ALIAS'] = 'bg_BG'; |
c30be3cf |
813 | |
e0e1b169 |
814 | $languages['bn_IN']['NAME'] = 'Bengali'; |
815 | $languages['bn_IN']['CHARSET'] = 'utf-8'; |
816 | $languages['bn_IN']['LOCALE'] = 'bn_IN.UTF-8'; |
817 | $languages['bn']['ALIAS'] = 'bn_IN'; |
a8fa8e33 |
818 | |
e0e1b169 |
819 | $languages['ca_ES']['NAME'] = 'Catalan'; |
820 | $languages['ca_ES']['CHARSET'] = 'iso-8859-1'; |
821 | $languages['ca_ES']['LOCALE'] = 'ca_ES.ISO8859-1'; |
822 | $languages['ca']['ALIAS'] = 'ca_ES'; |
a8fa8e33 |
823 | |
e0e1b169 |
824 | $languages['cs_CZ']['NAME'] = 'Czech'; |
825 | $languages['cs_CZ']['ALTNAME'] = 'Čeština'; |
826 | $languages['cs_CZ']['CHARSET'] = 'iso-8859-2'; |
827 | $languages['cs_CZ']['LOCALE'] = 'cs_CZ.ISO8859-2'; |
828 | $languages['cs']['ALIAS'] = 'cs_CZ'; |
4417eead |
829 | |
e0e1b169 |
830 | $languages['cy_GB']['NAME'] = 'Welsh'; |
831 | $languages['cy_GB']['ALTNAME'] = 'Cymraeg'; |
832 | $languages['cy_GB']['CHARSET'] = 'iso-8859-1'; |
833 | $languages['cy_GB']['LOCALE'] = 'cy_GB.ISO8859-1'; |
834 | $languages['cy']['ALIAS'] = 'cy_GB'; |
d3b57948 |
835 | |
e0e1b169 |
836 | // Danish locale is da_DK. |
837 | $languages['da_DK']['NAME'] = 'Danish'; |
838 | $languages['da_DK']['ALTNAME'] = 'Dansk'; |
839 | $languages['da_DK']['CHARSET'] = 'iso-8859-1'; |
840 | $languages['da_DK']['LOCALE'] = 'da_DK.ISO8859-1'; |
841 | $languages['da']['ALIAS'] = 'da_DK'; |
2ba590f9 |
842 | |
e0e1b169 |
843 | $languages['de_DE']['NAME'] = 'German'; |
844 | $languages['de_DE']['ALTNAME'] = 'Deutsch'; |
845 | $languages['de_DE']['CHARSET'] = 'iso-8859-1'; |
846 | $languages['de_DE']['LOCALE'] = 'de_DE.ISO8859-1'; |
847 | $languages['de']['ALIAS'] = 'de_DE'; |
a2a7852b |
848 | |
e0e1b169 |
849 | $languages['el_GR']['NAME'] = 'Greek'; |
850 | $languages['el_GR']['ALTNAME'] = 'Ελληνικά'; |
851 | $languages['el_GR']['CHARSET'] = 'iso-8859-7'; |
852 | $languages['el_GR']['LOCALE'] = 'el_GR.ISO8859-7'; |
853 | $languages['el']['ALIAS'] = 'el_GR'; |
3b84e1b1 |
854 | |
e0e1b169 |
855 | $languages['en_GB']['NAME'] = 'British'; |
856 | $languages['en_GB']['CHARSET'] = 'iso-8859-15'; |
857 | $languages['en_GB']['LOCALE'] = 'en_GB.ISO8859-15'; |
3b84e1b1 |
858 | |
e0e1b169 |
859 | $languages['en_US']['NAME'] = 'English'; |
860 | $languages['en_US']['CHARSET'] = 'iso-8859-1'; |
861 | $languages['en_US']['LOCALE'] = 'en_US.ISO8859-1'; |
862 | $languages['en']['ALIAS'] = 'en_US'; |
a2a7852b |
863 | |
e0e1b169 |
864 | $languages['es_ES']['NAME'] = 'Spanish'; |
865 | $languages['es_ES']['ALTNAME'] = 'Español'; |
866 | $languages['es_ES']['CHARSET'] = 'iso-8859-1'; |
867 | $languages['es_ES']['LOCALE'] = 'es_ES.ISO8859-1'; |
868 | $languages['es']['ALIAS'] = 'es_ES'; |
1d33e35e |
869 | |
e0e1b169 |
870 | $languages['et_EE']['NAME'] = 'Estonian'; |
871 | $languages['et_EE']['CHARSET'] = 'iso-8859-15'; |
872 | $languages['et_EE']['LOCALE'] = 'et_EE.ISO8859-15'; |
873 | $languages['et']['ALIAS'] = 'et_EE'; |
62f7daa5 |
874 | |
e0e1b169 |
875 | $languages['eu_ES']['NAME'] = 'Basque'; |
876 | $languages['eu_ES']['CHARSET'] = 'iso-8859-1'; |
877 | $languages['eu_ES']['LOCALE'] = 'eu_ES.ISO8859-1'; |
878 | $languages['eu']['ALIAS'] = 'eu_ES'; |
1d33e35e |
879 | |
e0e1b169 |
880 | $languages['fo_FO']['NAME'] = 'Faroese'; |
881 | $languages['fo_FO']['CHARSET'] = 'iso-8859-1'; |
882 | $languages['fo_FO']['LOCALE'] = 'fo_FO.ISO8859-1'; |
883 | $languages['fo']['ALIAS'] = 'fo_FO'; |
1d33e35e |
884 | |
e0e1b169 |
885 | $languages['fi_FI']['NAME'] = 'Finnish'; |
886 | $languages['fi_FI']['ALTNAME'] = 'Suomi'; |
887 | $languages['fi_FI']['CHARSET'] = 'iso-8859-1'; |
888 | $languages['fi_FI']['LOCALE'] = 'fi_FI.ISO8859-1'; |
889 | $languages['fi']['ALIAS'] = 'fi_FI'; |
1bb86586 |
890 | |
e0e1b169 |
891 | $languages['fr_FR']['NAME'] = 'French'; |
892 | $languages['fr_FR']['ALTNAME'] = 'Français'; |
893 | $languages['fr_FR']['CHARSET'] = 'iso-8859-1'; |
894 | $languages['fr_FR']['LOCALE'] = 'fr_FR.ISO8859-1'; |
895 | $languages['fr']['ALIAS'] = 'fr_FR'; |
1bb86586 |
896 | |
e0e1b169 |
897 | $languages['hr_HR']['NAME'] = 'Croatian'; |
898 | $languages['hr_HR']['CHARSET'] = 'iso-8859-2'; |
899 | $languages['hr_HR']['LOCALE'] = 'hr_HR.ISO8859-2'; |
900 | $languages['hr']['ALIAS'] = 'hr_HR'; |
62f7daa5 |
901 | |
e0e1b169 |
902 | $languages['hu_HU']['NAME'] = 'Hungarian'; |
903 | $languages['hu_HU']['ALTNAME'] = 'Magyar'; |
904 | $languages['hu_HU']['CHARSET'] = 'iso-8859-2'; |
905 | $languages['hu_HU']['LOCALE'] = 'hu_HU.ISO8859-2'; |
906 | $languages['hu']['ALIAS'] = 'hu_HU'; |
1bb86586 |
907 | |
e0e1b169 |
908 | $languages['id_ID']['NAME'] = 'Indonesian'; |
909 | $languages['id_ID']['ALTNAME'] = 'Bahasa Indonesia'; |
910 | $languages['id_ID']['CHARSET'] = 'iso-8859-1'; |
911 | $languages['id_ID']['LOCALE'] = 'id_ID.ISO8859-1'; |
912 | $languages['id']['ALIAS'] = 'id_ID'; |
1bb86586 |
913 | |
e0e1b169 |
914 | $languages['is_IS']['NAME'] = 'Icelandic'; |
915 | $languages['is_IS']['ALTNAME'] = 'Íslenska'; |
916 | $languages['is_IS']['CHARSET'] = 'iso-8859-1'; |
917 | $languages['is_IS']['LOCALE'] = 'is_IS.ISO8859-1'; |
918 | $languages['is']['ALIAS'] = 'is_IS'; |
1bb86586 |
919 | |
e0e1b169 |
920 | $languages['it_IT']['NAME'] = 'Italian'; |
921 | $languages['it_IT']['CHARSET'] = 'iso-8859-1'; |
922 | $languages['it_IT']['LOCALE'] = 'it_IT.ISO8859-1'; |
923 | $languages['it']['ALIAS'] = 'it_IT'; |
1bb86586 |
924 | |
e0e1b169 |
925 | $languages['ja_JP']['NAME'] = 'Japanese'; |
926 | $languages['ja_JP']['ALTNAME'] = '日本語'; |
927 | $languages['ja_JP']['CHARSET'] = 'iso-2022-jp'; |
928 | $languages['ja_JP']['LOCALE'] = 'ja_JP.EUC-JP'; |
929 | $languages['ja_JP']['XTRA_CODE'] = 'japanese_xtra'; |
930 | $languages['ja']['ALIAS'] = 'ja_JP'; |
62f7daa5 |
931 | |
e0e1b169 |
932 | $languages['ko_KR']['NAME'] = 'Korean'; |
933 | $languages['ko_KR']['CHARSET'] = 'euc-KR'; |
934 | $languages['ko_KR']['LOCALE'] = 'ko_KR.EUC-KR'; |
935 | $languages['ko_KR']['XTRA_CODE'] = 'korean_xtra'; |
936 | $languages['ko']['ALIAS'] = 'ko_KR'; |
1bb86586 |
937 | |
e0e1b169 |
938 | $languages['lt_LT']['NAME'] = 'Lithuanian'; |
939 | $languages['lt_LT']['ALTNAME'] = 'Lietuvių'; |
940 | $languages['lt_LT']['CHARSET'] = 'utf-8'; |
941 | $languages['lt_LT']['LOCALE'] = 'lt_LT.UTF-8'; |
942 | $languages['lt']['ALIAS'] = 'lt_LT'; |
62f7daa5 |
943 | |
e0e1b169 |
944 | $languages['nl_NL']['NAME'] = 'Dutch'; |
945 | $languages['nl_NL']['ALTNAME'] = 'Nederlands'; |
946 | $languages['nl_NL']['CHARSET'] = 'iso-8859-1'; |
947 | $languages['nl_NL']['LOCALE'] = 'nl_NL.ISO8859-1'; |
948 | $languages['nl']['ALIAS'] = 'nl_NL'; |
62f7daa5 |
949 | |
e0e1b169 |
950 | $languages['ms_MY']['NAME'] = 'Malay'; |
951 | $languages['ms_MY']['ALTNAME'] = 'Bahasa Melayu'; |
952 | $languages['ms_MY']['CHARSET'] = 'iso-8859-1'; |
953 | $languages['ms_MY']['LOCALE'] = 'ms_MY.ISO8859-1'; |
954 | $languages['my']['ALIAS'] = 'ms_MY'; |
62f7daa5 |
955 | |
e0e1b169 |
956 | $languages['nb_NO']['NAME'] = 'Norwegian (Bokmål)'; |
957 | $languages['nb_NO']['ALTNAME'] = 'Norsk (Bokmål)'; |
958 | $languages['nb_NO']['CHARSET'] = 'iso-8859-1'; |
959 | $languages['nb_NO']['LOCALE'] = 'nb_NO.ISO8859-1'; |
960 | $languages['nb']['ALIAS'] = 'nb_NO'; |
1bb86586 |
961 | |
e0e1b169 |
962 | $languages['nn_NO']['NAME'] = 'Norwegian (Nynorsk)'; |
963 | $languages['nn_NO']['ALTNAME'] = 'Norsk (Nynorsk)'; |
964 | $languages['nn_NO']['CHARSET'] = 'iso-8859-1'; |
965 | $languages['nn_NO']['LOCALE'] = 'nn_NO.ISO8859-1'; |
1bb86586 |
966 | |
e0e1b169 |
967 | $languages['pl_PL']['NAME'] = 'Polish'; |
968 | $languages['pl_PL']['ALTNAME'] = 'Polski'; |
969 | $languages['pl_PL']['CHARSET'] = 'iso-8859-2'; |
970 | $languages['pl_PL']['LOCALE'] = 'pl_PL.ISO8859-2'; |
971 | $languages['pl']['ALIAS'] = 'pl_PL'; |
1bb86586 |
972 | |
e0e1b169 |
973 | $languages['pt_PT']['NAME'] = 'Portuguese (Portugal)'; |
974 | $languages['pt_PT']['CHARSET'] = 'iso-8859-1'; |
975 | $languages['pt_PT']['LOCALE'] = 'pt_PT.ISO8859-1'; |
976 | $languages['pt']['ALIAS'] = 'pt_PT'; |
1bb86586 |
977 | |
e0e1b169 |
978 | $languages['pt_BR']['NAME'] = 'Portuguese (Brazil)'; |
979 | $languages['pt_BR']['ALTNAME'] = 'Português do Brasil'; |
980 | $languages['pt_BR']['CHARSET'] = 'iso-8859-1'; |
981 | $languages['pt_BR']['LOCALE'] = 'pt_BR.ISO8859-1'; |
1bb86586 |
982 | |
e0e1b169 |
983 | $languages['ro_RO']['NAME'] = 'Romanian'; |
984 | $languages['ro_RO']['ALTNAME'] = 'Română'; |
985 | $languages['ro_RO']['CHARSET'] = 'iso-8859-2'; |
986 | $languages['ro_RO']['LOCALE'] = 'ro_RO.ISO8859-2'; |
987 | $languages['ro']['ALIAS'] = 'ro_RO'; |
1d33e35e |
988 | |
e0e1b169 |
989 | $languages['ru_RU']['NAME'] = 'Russian'; |
990 | $languages['ru_RU']['ALTNAME'] = 'Русский'; |
991 | $languages['ru_RU']['CHARSET'] = 'utf-8'; |
992 | $languages['ru_RU']['LOCALE'] = 'ru_RU.UTF-8'; |
993 | $languages['ru']['ALIAS'] = 'ru_RU'; |
9af9c0a2 |
994 | |
e0e1b169 |
995 | $languages['sk_SK']['NAME'] = 'Slovak'; |
996 | $languages['sk_SK']['CHARSET'] = 'iso-8859-2'; |
997 | $languages['sk_SK']['LOCALE'] = 'sk_SK.ISO8859-2'; |
998 | $languages['sk']['ALIAS'] = 'sk_SK'; |
9af9c0a2 |
999 | |
e0e1b169 |
1000 | $languages['sl_SI']['NAME'] = 'Slovenian'; |
1001 | $languages['sl_SI']['ALTNAME'] = 'Slovenščina'; |
1002 | $languages['sl_SI']['CHARSET'] = 'iso-8859-2'; |
1003 | $languages['sl_SI']['LOCALE'] = 'sl_SI.ISO8859-2'; |
1004 | $languages['sl']['ALIAS'] = 'sl_SI'; |
9af9c0a2 |
1005 | |
e0e1b169 |
1006 | $languages['sr_YU']['NAME'] = 'Serbian'; |
1007 | $languages['sr_YU']['ALTNAME'] = 'Srpski'; |
1008 | $languages['sr_YU']['CHARSET'] = 'iso-8859-2'; |
1009 | $languages['sr_YU']['LOCALE'] = 'sr_YU.ISO8859-2'; |
1010 | $languages['sr']['ALIAS'] = 'sr_YU'; |
4e519821 |
1011 | |
e0e1b169 |
1012 | $languages['sv_SE']['NAME'] = 'Swedish'; |
1013 | $languages['sv_SE']['ALTNAME'] = 'Svenska'; |
1014 | $languages['sv_SE']['CHARSET'] = 'iso-8859-1'; |
1015 | $languages['sv_SE']['LOCALE'] = 'sv_SE.ISO8859-1'; |
1016 | $languages['sv']['ALIAS'] = 'sv_SE'; |
33991968 |
1017 | |
e0e1b169 |
1018 | $languages['th_TH']['NAME'] = 'Thai'; |
1019 | $languages['th_TH']['CHARSET'] = 'tis-620'; |
1020 | $languages['th_TH']['LOCALE'] = 'th_TH.TIS-620'; |
1021 | $languages['th']['ALIAS'] = 'th_TH'; |
4e519821 |
1022 | |
e0e1b169 |
1023 | $languages['tl_PH']['NAME'] = 'Tagalog'; |
1024 | $languages['tl_PH']['CHARSET'] = 'iso-8859-1'; |
1025 | $languages['tl_PH']['LOCALE'] = 'tl_PH.ISO8859-1'; |
1026 | $languages['tl']['ALIAS'] = 'tl_PH'; |
4e519821 |
1027 | |
e0e1b169 |
1028 | $languages['tr_TR']['NAME'] = 'Turkish'; |
1029 | $languages['tr_TR']['CHARSET'] = 'iso-8859-9'; |
1030 | $languages['tr_TR']['LOCALE'] = 'tr_TR.ISO8859-9'; |
1031 | $languages['tr']['ALIAS'] = 'tr_TR'; |
4e519821 |
1032 | |
e0e1b169 |
1033 | $languages['zh_TW']['NAME'] = 'Chinese Trad'; |
1034 | $languages['zh_TW']['CHARSET'] = 'big5'; |
1035 | $languages['zh_TW']['LOCALE'] = 'zh_TW.BIG5'; |
1036 | $languages['tw']['ALIAS'] = 'zh_TW'; |
1037 | |
1038 | $languages['zh_CN']['NAME'] = 'Chinese Simp'; |
1039 | $languages['zh_CN']['CHARSET'] = 'gb2312'; |
1040 | $languages['zh_CN']['LOCALE'] = 'zh_CN.GB2312'; |
1041 | $languages['cn']['ALIAS'] = 'zh_CN'; |
1042 | |
1043 | $languages['uk_UA']['NAME'] = 'Ukrainian'; |
1044 | $languages['uk_UA']['CHARSET'] = 'koi8-u'; |
1045 | $languages['uk_UA']['LOCALE'] = 'uk_UA.KOI8-U'; |
1046 | $languages['uk']['ALIAS'] = 'uk_UA'; |
1047 | |
1048 | $languages['ru_UA']['NAME'] = 'Russian (Ukrainian)'; |
1049 | $languages['ru_UA']['CHARSET'] = 'koi8-r'; |
1050 | $languages['ru_UA']['LOCALE'] = 'ru_UA.KOI8-R'; |
1051 | |
1052 | /* |
1053 | $languages['vi_VN']['NAME'] = 'Vietnamese'; |
1054 | $languages['vi_VN']['CHARSET'] = 'utf-8'; |
1055 | $languages['vi']['ALIAS'] = 'vi_VN'; |
1056 | */ |
1057 | |
1058 | // Right to left languages |
1059 | $languages['ar']['NAME'] = 'Arabic'; |
1060 | $languages['ar']['CHARSET'] = 'windows-1256'; |
1061 | $languages['ar']['DIR'] = 'rtl'; |
1062 | |
1063 | $languages['fa_IR']['NAME'] = 'Farsi'; |
1064 | $languages['fa_IR']['CHARSET'] = 'utf-8'; |
1065 | $languages['fa_IR']['DIR'] = 'rtl'; |
1066 | $languages['fa_IR']['LOCALE'] = 'fa_IR.UTF-8'; |
1067 | $languages['fa']['ALIAS'] = 'fa_IR'; |
1068 | |
1069 | $languages['he_IL']['NAME'] = 'Hebrew'; |
1070 | $languages['he_IL']['CHARSET'] = 'windows-1255'; |
1071 | $languages['he_IL']['LOCALE'] = 'he_IL.CP1255'; |
1072 | $languages['he_IL']['DIR'] = 'rtl'; |
1073 | $languages['he']['ALIAS'] = 'he_IL'; |
1074 | |
1075 | $languages['ug']['NAME'] = 'Uighur'; |
1076 | $languages['ug']['CHARSET'] = 'utf-8'; |
1077 | $languages['ug']['DIR'] = 'rtl'; |
1078 | |
1079 | /* Detect whether gettext is installed. */ |
1080 | $gettext_flags = 0; |
1081 | if (function_exists('_')) { |
1082 | $gettext_flags += 1; |
1083 | } |
1084 | if (function_exists('bindtextdomain')) { |
1085 | $gettext_flags += 2; |
1086 | } |
1087 | if (function_exists('textdomain')) { |
1088 | $gettext_flags += 4; |
1089 | } |
1090 | if (function_exists('ngettext')) { |
1091 | $gettext_flags += 8; |
1092 | } |
1093 | |
1094 | /* If gettext is fully loaded, cool */ |
1095 | if ($gettext_flags == 15) { |
1096 | $use_gettext = true; |
1097 | } |
1098 | |
1099 | /* If ngettext support is missing, load it */ |
1100 | elseif ($gettext_flags == 7) { |
1101 | $use_gettext = true; |
1102 | // load internal ngettext functions |
1103 | include_once(SM_PATH . 'class/l10n.class.php'); |
1104 | include_once(SM_PATH . 'functions/ngettext.php'); |
1105 | } |
1106 | |
1107 | /* If we can fake gettext, try that */ |
1108 | elseif ($gettext_flags == 0) { |
1109 | $use_gettext = true; |
1110 | include_once(SM_PATH . 'functions/gettext.php'); |
1111 | } else { |
1112 | /* Uh-ho. A weird install */ |
1113 | if (! $gettext_flags & 1) { |
1114 | /** |
1115 | * Function is used as replacement in broken installs |
1116 | * @ignore |
1117 | */ |
1118 | function _($str) { |
1119 | return $str; |
1120 | } |
1121 | } |
1122 | if (! $gettext_flags & 2) { |
1123 | /** |
1124 | * Function is used as replacement in broken installs |
1125 | * @ignore |
1126 | */ |
1127 | function bindtextdomain() { |
1128 | return; |
1129 | } |
1130 | } |
1131 | if (! $gettext_flags & 4) { |
1132 | /** |
1133 | * Function is used as replacemet in broken installs |
1134 | * @ignore |
1135 | */ |
1136 | function textdomain() { |
1137 | return; |
1138 | } |
1139 | } |
1140 | if (! $gettext_flags & 8) { |
1141 | /** |
1142 | * Function is used as replacemet in broken installs |
1143 | * @ignore |
1144 | */ |
1145 | function ngettext($str,$str2,$number) { |
1146 | if ($number>1) { |
1147 | return $str2; |
1148 | } else { |
1149 | return $str; |
1150 | } |
1151 | } |
1152 | } |
4e519821 |
1153 | } |
51468260 |
1154 | ?> |