Selaa lähdekoodia

Made page encoding a function if the users selected language.

gustavf 25 vuotta sitten
vanhempi
commit
78c15ca561
3 muutettua tiedostoa jossa 21 lisäystä ja 17 poistoa
  1. 7 8
      functions/i18n.php
  2. 7 5
      functions/page_header.php
  3. 7 4
      src/options.php

+ 7 - 8
functions/i18n.php

@@ -14,14 +14,13 @@
    $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) {

+ 7 - 5
functions/page_header.php

@@ -10,11 +10,8 @@
 
    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.
@@ -37,6 +35,10 @@
       }
    }
 
+   // 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, ".");

+ 7 - 4
src/options.php

@@ -90,13 +90,16 @@
    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>";