Bladeren bron

Bugfixes in l10n

graf25 24 jaren geleden
bovenliggende
commit
d561672259
3 gewijzigde bestanden met toevoegingen van 33 en 4 verwijderingen
  1. 23 1
      functions/i18n.php
  2. 6 2
      functions/page_header.php
  3. 4 1
      src/compose.php

+ 23 - 1
functions/i18n.php

@@ -762,7 +762,9 @@
       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);
       }
@@ -777,6 +779,26 @@
          bindtextdomain('squirrelmail', '../locale/');
          textdomain('squirrelmail');
          header ('Content-Type: text/html; charset=' . $languages[$sm_language]['CHARSET']);
+         $charset_headers_sent=true;
       }
+      return $charset_headers_sent;
    }
+
+   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;
+     $my_charset=$languages[$my_language]['CHARSET'];
+     if ($my_charset) $default_charset=$my_charset;
+   }
+
 ?>

+ 6 - 2
functions/page_header.php

@@ -19,10 +19,14 @@
       include ("../functions/plugin.php");
 
    // Check to see if gettext is installed
-   set_up_language(getPref($data_dir, $username, "language"));
+   $headers_sent=set_up_language(getPref($data_dir, $username, "language"));
 
    // This is done to ensure that the character set is correct.
-   if ($default_charset != "")
+   // But first checks whether we have already sent headers
+   // with charset when we were setting up the user language.
+   // Otherwise user ends up with the default charset overriding
+   // his selected one.
+   if (!$headers_sent && $default_charset != "")
       header ("Content-Type: text/html; charset=$default_charset");
 
    function displayHtmlHeader ($title="SquirrelMail") {

+ 4 - 1
src/compose.php

@@ -426,7 +426,10 @@
          $urlMailbox = urlencode (trim($mailbox));
          if (! isset($reply_id))
              $reply_id = 0;
-         sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id);
+         // Set $default_charset to correspond with the user's selection
+	 // of language interface.
+	 set_my_charset();
+	 sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id);
          header ("Location: right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=1");
       } else {
          //$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);