X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fi18n.php;h=2ce457b1f144020b2dfb771ae0a6f10a29749d50;hb=cb48c2455cde2cf6ba67944c45decc4eca7df306;hp=2cad11eefe6e13073688c3b937e5c42034a96ef2;hpb=a89c13f5e0b27dd9610a4684104f35c93d703122;p=squirrelmail.git diff --git a/functions/i18n.php b/functions/i18n.php index 2cad11ee..2ce457b1 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -1,46 +1,150 @@ + + // Set up the language to be output + // if $do_search is true, then scan the browser information + // for a possible language that we know + function set_up_language($sm_language, $do_search = false) { + static $SetupAlready = 0; + global $HTTP_ACCEPT_LANGUAGE, $use_gettext, $languages, + $squirrelmail_language, $squirrelmail_default_language, + $sm_notAlias; + + if ($SetupAlready) + return; + + $SetupAlready = 1; + + $charset_headers_sent=false; + + if ($do_search && ! $sm_language && isset($HTTP_ACCEPT_LANGUAGE)) { + $sm_language = substr($HTTP_ACCEPT_LANGUAGE, 0, 2); + } + if (!$sm_language && isset($squirrelmail_default_language)) + $squirrelmail_language = $squirrelmail_default_language; + $sm_notAlias = $sm_language; + while (isset($languages[$sm_notAlias]['ALIAS'])) + $sm_notAlias = $languages[$sm_notAlias]['ALIAS']; + + if (isset($sm_language) && $use_gettext && + $sm_language != '' && + isset($languages[$sm_notAlias]['CHARSET'])) { + if ((ini_get('safe_mode') == FALSE) && (getenv('LC_ALL') != $sm_language)) { + putenv('LC_ALL=' . $sm_notAlias); + } + setlocale('LC_ALL', $sm_notAlias); + bindtextdomain('squirrelmail', '../locale/'); + textdomain('squirrelmail'); + header ('Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET']); + } + } + + function set_my_charset(){ + // + // There can be a $default_charset setting in the + // config.php file, but the user may have a different language + // selected for a user interface. This function checks the + // language selected by the user and tags the outgoing messages + // with the appropriate charset corresponding to the language + // selection. This is "more right" (tm), than just stamping the + // message blindly with the system-wide $default_charset. + // + global $data_dir, $username, $default_charset, $languages; + $my_language = getPref($data_dir, $username, "language"); + if (!$my_language) return; + while (isset($languages[$my_language]['ALIAS'])) + $my_language = $languages[$my_language]['ALIAS']; + $my_charset=$languages[$my_language]['CHARSET']; + if ($my_charset) $default_charset=$my_charset; + } + +?> \ No newline at end of file