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