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