X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fi18n.php;h=a56f4f426f07e10ea7ce185a8876b85159178b09;hb=2198d485d5b406f3f007f5c0146b275fb8272326;hp=8ff0dae4b6e266f7e32bd7ce7cf69e6d5b37c24e;hpb=c6cd3136ff62b3fd367052e7bafb959b8a15a465;p=squirrelmail.git diff --git a/functions/i18n.php b/functions/i18n.php index 8ff0dae4..a56f4f42 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -1,16 +1,16 @@ '),$string); return $string; } } @@ -160,14 +166,13 @@ function charset_decode ($charset, $string, $force_decode=false) { // iconv functions does not have html target and can be used only with utf-8 if ( $use_php_iconv && $default_charset=='utf-8') { $string = iconv($charset,$default_charset,$string); - return htmlspecialchars($string); + return ($save_html ? $string : htmlspecialchars($string)); } // If we don't use recode and iconv, we'll do it old way. /* All HTML special characters are 7 bit and can be replaced first */ - - $string = htmlspecialchars ($string); + if (! $save_html) $string = htmlspecialchars ($string); /* controls cpu and memory intensive decoding cycles */ if (! isset($aggressive_decoding) || $aggressive_decoding=="" ) { @@ -177,7 +182,8 @@ function charset_decode ($charset, $string, $force_decode=false) { $decodefile=SM_PATH . 'functions/decode/' . $decode . '.php'; if (file_exists($decodefile)) { include_once($decodefile); - $ret = call_user_func('charset_decode_'.$decode, $string); + // send $save_html argument to decoding function. needed for iso-2022-xx decoding. + $ret = call_user_func('charset_decode_'.$decode, $string, $save_html); } else { $ret = $string; } @@ -255,6 +261,13 @@ function fixcharset($charset) { */ $charset=preg_replace("/[-:.\/\\\]/",'_',$charset); + // OE ks_c_5601_1987 > cp949 + $charset=str_replace('ks_c_5601_1987','cp949',$charset); + // Moz x-euc-tw > euc-tw + $charset=str_replace('x_euc','euc',$charset); + // Moz x-windows-949 > cp949 + $charset=str_replace('x_windows_','cp',$charset); + // windows-125x and cp125x charsets $charset=str_replace('windows_','cp',$charset); @@ -402,8 +415,13 @@ function set_up_language($sm_language, $do_search = false, $default = false) { // Many functions expect English conversion rules. if ($sm_notAlias=='tr_TR') setlocale(LC_CTYPE,'C'); - // Set text direction/alignment variables - // These don't appear to be used... are they safe to remove? + /** + * Set text direction/alignment variables + * When language environment is setup, scripts can use these globals + * without accessing $languages directly and making checks for optional + * array key. + */ + global $text_direction, $left_align, $right_align; if (isset($languages[$sm_notAlias]['DIR']) && $languages[$sm_notAlias]['DIR'] == 'rtl') { /** @@ -682,16 +700,21 @@ $languages['en']['ALIAS'] = 'en_US'; * Solution for bug. 1240889. * setup.php file can contain $languages array entries and XTRA_CODE functions. */ -foreach(glob(SM_PATH.'locale/*') as $lang_dir) { - // remove trailing slash, if present - if (substr($lang_dir,-1)=='/') { - $lang_dir = substr($lang_dir,0,-1); - } - // load language setup - if (is_dir(SM_PATH.'locale/'.$lang_dir) && - file_exists(SM_PATH.'locale/'.$lang_dir.'/setup.php')) { - include_once(SM_PATH.'locale/'.$lang_dir.'/setup.php'); +if (is_dir(SM_PATH . 'locale') && + is_readable(SM_PATH . 'locale')) { + $localedir = dir(SM_PATH . 'locale'); + while($lang_dir=$localedir->read()) { + // remove trailing slash, if present + if (substr($lang_dir,-1)=='/') { + $lang_dir = substr($lang_dir,0,-1); + } + if ($lang_dir != '..' && $lang_dir != '.' && $lang_dir != 'CVS' && + is_dir(SM_PATH.'locale/'.$lang_dir) && + file_exists(SM_PATH.'locale/'.$lang_dir.'/setup.php')) { + include_once(SM_PATH.'locale/'.$lang_dir.'/setup.php'); + } } + $localedir->close(); } /* Detect whether gettext is installed. */