Index: locale/ja_JP/setup.php =================================================================== --- locale/ja_JP/setup.php (revision 12897) +++ locale/ja_JP/setup.php (working copy) @@ -2,7 +2,7 @@ /** * Language configuration file * - * Copyright (c) 2005-2006 The SquirrelMail Project Team + * Copyright (c) 2005-2008 The SquirrelMail Project Team * * This file is part of SquirrelMail webmail interface. It is distributed * together with other translation files and is used to enable @@ -33,6 +33,19 @@ $languages['ja_JP']['XTRA_CODE'] = 'japanese_xtra'; $languages['ja']['ALIAS'] = 'ja_JP'; +$languages['ja_JP']['INTERNAL_CHARSET'] = 'EUC-JP'; + +/* + * force correct detection of charset, when browser does not follow + * http content-type and tries to detect charset from page content. + * Shooting of browser's creator can't be implemented in php. + * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/ + * recommendations and switch to unicode. + */ +$languages['ja_JP']['EXTRA_HEADER'] + = "\n" + . "\n"; + /************************** * Japanese extra functions **************************/ @@ -221,6 +234,19 @@ } /** + * Japanese wordwrap function + * + * unwraps text + * @param string $ret text + * @return string wrapped text + * @since 1.5.2 + */ +function japanese_xtra_unwordwrap(&$body) { + /* do nothing for japanese body. */ + return $body; +} + +/** * Japanese imap folder name encoding function * * converts folder name from euc-jp to utf7-imap @@ -265,3 +291,58 @@ } return $ret; } + +/** + * header() function and some workarounds which are specific to this language. + * @return int error code + * @since 1.5.2 + */ +function japanese_xtra_header() +{ + global $data_dir, $username, $squirrelmail_language; + + header ('Content-Type: text/html; charset=EUC-JP'); + if (!function_exists('mb_internal_encoding')) { + // Error messages can't be displayed here + $error = 1; + // Revert to English if possible. + if (function_exists('setPref') && $username != '' && $data_dir != "") { + setPref($data_dir, $username, 'language', "en_US"); + $error = 2; + } + // stop further execution in order not to get php errors on mb_internal_encoding(). + return $error; + } + + if (function_exists('mb_language')) { + mb_language('Japanese'); + } + mb_internal_encoding('EUC-JP'); + mb_http_output('pass'); + + + /** + * mbstring.func_overload fix (#929644). + * + * php mbstring extension can replace standard string functions with their multibyte + * equivalents. See http://www.php.net/ref.mbstring#mbstring.overload. This feature + * was added in php v.4.2.0 + * + * Some SquirrelMail functions work with 8bit strings in bytes. If interface is forced + * to use mbstring functions and mbstring internal encoding is set to multibyte charset, + * interface can't trust regular string functions. Due to mbstring overloading design + * limits php scripts can't control this setting. + * + * This hack should fix some issues related to 8bit strings in passwords. Correct fix is + * to disable mbstring overloading. Japanese translation uses different internal encoding. + */ + if ( $squirrelmail_language != 'ja_JP' && + function_exists('mb_internal_encoding') && + check_php_version(4, 2, 0) && + (int)ini_get('mbstring.func_overload') != 0) { + mb_internal_encoding('pass'); + } +} + + +?>