Update message copy and move functions to allow for custom handling / ignoring of...
[squirrelmail.git] / functions / i18n.php
index 37cde724145446421e7ebae38871ff0a79162ed7..7b0c3813b38a1cb26c1c76b5beccd7209009cfbf 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * SquirrelMail internationalization functions
  *
- * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * Copyright (c) 1999-2005 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * This file contains variuos functions that are needed to do
@@ -66,11 +66,11 @@ function sq_textdomain($domain) {
  * php gettext extension works only when locale is set. This wrapper
  * function allows to use more than one locale name.
  *
- * @param int $category locale category name. Use php named constants 
- *     (LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME)  
+ * @param int $category locale category name. Use php named constants
+ *     (LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME)
  * @param mixed $locale option contains array with possible locales or string with one locale
  * @return string name of set locale or false, if all locales fail.
- * @since 1.5.1
+ * @since 1.5.1 and 1.4.5
  * @see http://www.php.net/setlocale
  */
 function sq_setlocale($category,$locale) {
@@ -104,9 +104,11 @@ function sq_setlocale($category,$locale) {
  *
  * @param string $charset
  * @param string $string Text to be decoded
+ * @param boolean $force_decode converts string to html without $charset!=$default_charset check. 
+ * Argument is available since 1.5.1 and 1.4.5.
  * @return string decoded string
  */
-function charset_decode ($charset, $string) {
+function charset_decode ($charset, $string, $force_decode=false) {
     global $languages, $squirrelmail_language, $default_charset;
     global $use_php_recode, $use_php_iconv, $aggressive_decoding;
 
@@ -126,7 +128,7 @@ function charset_decode ($charset, $string) {
         $use_php_iconv=false; }
 
     // Don't do conversion if charset is the same.
-    if ( $charset == strtolower($default_charset) )
+    if ( ! $force_decode && $charset == strtolower($default_charset) )
         return htmlspecialchars($string);
 
     // catch iso-8859-8-i thing
@@ -181,7 +183,7 @@ function charset_decode ($charset, $string) {
 
 /**
  * Converts html string to given charset
- * @since 1.5.1
+ * @since 1.5.1 and 1.4.4
  * @param string $string
  * @param string $charset
  * @param boolean $htmlencode keep htmlspecialchars encoding
@@ -217,7 +219,7 @@ function charset_encode($string,$charset,$htmlencode=true) {
  *
  * If conversion is done to charset different that utf-8, unsupported symbols
  * will be replaced with question marks.
- * @since 1.5.1
+ * @since 1.5.1 and 1.4.4
  * @param string $in_charset initial charset
  * @param string $string string that has to be converted
  * @param string $out_charset final charset
@@ -225,7 +227,7 @@ function charset_encode($string,$charset,$htmlencode=true) {
  * @return string converted string
  */
 function charset_convert($in_charset,$string,$out_charset,$htmlencode=true) {
-    $string=charset_decode($in_charset,$string);
+    $string=charset_decode($in_charset,$string,true);
     $string=charset_encode($string,$out_charset,$htmlencode);
     return $string;
 }
@@ -233,7 +235,7 @@ function charset_convert($in_charset,$string,$out_charset,$htmlencode=true) {
 /**
  * Makes charset name suitable for decoding cycles
  *
- * @since 1.5.0
+ * @since 1.5.0 and 1.4.4
  * @param string $charset Name of charset
  * @return string $charset Adjusted name of charset
  */
@@ -320,9 +322,9 @@ function set_up_language($sm_language, $do_search = false, $default = false) {
         if (function_exists('bind_textdomain_codeset')) {
             // Japanese translation uses different internal charset
             if ($sm_notAlias == 'ja_JP') {
-                bind_textdomain_codeset ("squirrelmail", 'EUC-JP');
+                bind_textdomain_codeset ('squirrelmail', 'EUC-JP');
             } else {
-                bind_textdomain_codeset ("squirrelmail", $languages[$sm_notAlias]['CHARSET'] );
+                bind_textdomain_codeset ('squirrelmail', $languages[$sm_notAlias]['CHARSET'] );
             }
         }
 
@@ -863,7 +865,7 @@ if (! isset($squirrelmail_language)) {
  *  CHARSET   - Encoding used by translation
  *  ALIAS     - used when 'language' is only short name and 'value' should provide long language name
  *  ALTNAME   - Native translation name. Any 8bit symbols must be html encoded.
- *  LOCALE    - Full locale name (in xx_XX.charset format)
+ *  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
  *  DIR       - Text direction. Used to define Right-to-Left languages. Possible values 'rtl' or 'ltr'. If undefined - defaults to 'ltr'
  *  XTRA_CODE - translation uses special functions. See doc/i18n.txt
  *