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