Made page encoding a function if the users selected language.
authorgustavf <gustavf@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 24 Mar 2000 11:35:51 +0000 (11:35 +0000)
committergustavf <gustavf@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 24 Mar 2000 11:35:51 +0000 (11:35 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@328 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/i18n.php
functions/page_header.php
src/options.php

index 54d65e1f37a391813460f206ef0afc003066e0bf..13c31124365584694603cd980ba861ca7ba07c5a 100644 (file)
    $i18n_php = true;
 
    // This array specifies the available languages.
-   $languages[0]["NAME"] = "English";
-   $languages[0]["CODE"] = "en";
-   $languages[1]["NAME"] = "Norsk";
-   $languages[1]["CODE"] = "no";
-   $languages[2]["NAME"] = "Deutcsh";
-   $languages[2]["CODE"] = "de";
-   $languages[2]["NAME"] = "Russian KOI8-R";
-   $languages[2]["CODE"] = "ru";
+   $languages["en"]["NAME"]    = "English";
+   $languages["no"]["NAME"]    = "Norsk";
+   $languages["no"]["CHARSET"] = "iso-8859-1";
+   $languages["de"]["NAME"]    = "Deutcsh";
+   $languages["de"]["CHARSET"] = "iso-8859-1";
+   $languages["ru"]["NAME"]    = "Russian KOI8-R";
+   $languages["ru"]["CHARSET"] = "koi8-r";
 
    // Decodes a string to the internal encoding from the given charset
    function charset_decode ($charset, $string) {
index fb92f887c02885c172b65b50ad40cc030dc6a185..849dd81f324fa592a279f3573cac085563496149 100644 (file)
 
    if (!isset($prefs_php))
       include ("../functions/prefs.php");
-
-   // This is done to ensure that the character set is correct when
-   // receiving input from HTTP forms
-   if ($default_charset != "")
-      header ("Content-Type: text/html; charset=$default_charset");
+   if (!isset($i18n_php))
+      include ("../functions/i18n.php");
 
    // Check to see if gettext is installed
    if (function_exists("_")) {
@@ -25,6 +22,7 @@
          putenv("LANG=$squirrelmail_language");
          bindtextdomain("squirrelmail", "../locale/");
          textdomain("squirrelmail");
+         $default_charset = $languages[$squirrelmail_language]["CHARSET"];
          
          // Setting cookie to use on the login screen the next time the
          // same user logs in.
       }
    }
 
+   // This is done to ensure that the character set is correct.
+   if ($default_charset != "")
+      header ("Content-Type: text/html; charset=$default_charset");
+
    function displayPageHeader($color, $mailbox) {
       /** Here is the header and wrapping table **/
       $shortBoxName = readShortMailboxName($mailbox, ".");
index 83d58fb43f696ed50993899ea62e49d6d2a3439f..425311afb35cb13e020017f58773ac3de870b088 100644 (file)
    echo "      <TD WIDTH=80% ALIGN=LEFT>";
 
    echo "         <TT><SELECT NAME=language>\n";
-   for ($i = 0; $i < count($languages); $i++) {
-      if ($languages[$i]["CODE"] == $chosen_language)
-         echo "         <OPTION SELECTED VALUE=\"".$languages[$i]["CODE"]."\">".$languages[$i]["NAME"]."\n";
+   reset ($languages);
+   while (list($code, $name)=each($languages)) {
+      if ($code==$chosen_language)
+         echo "         <OPTION SELECTED VALUE=\"".$code."\">".$languages[$code]["NAME"]."\n";
       else
-         echo "         <OPTION VALUE=\"".$languages[$i]["CODE"]."\">".$languages[$i]["NAME"]."\n";
+         echo "         <OPTION VALUE=\"".$code."\">".$languages[$code]["NAME"]."\n";
+
    }
    echo "         </SELECT></TT>";
+
    echo "      </TD>";
    echo "   </TR>";
    echo "</TABLE>";