Forráskód Böngészése

Added setting of language and a brief Norwegian translation.

gustavf 25 éve
szülő
commit
3e93f03caa
6 módosított fájl, 58 hozzáadás és 4 törlés
  1. 6 0
      functions/i18n.php
  2. 20 0
      functions/page_header.php
  3. 3 1
      src/load_prefs.php
  4. 6 3
      src/login.php
  5. 22 0
      src/options.php
  6. 1 0
      src/options_submit.php

+ 6 - 0
functions/i18n.php

@@ -13,6 +13,12 @@
 
    $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";
+
    // Decodes a string to the internal encoding from the given charset
    function charset_decode ($charset, $string) {
       // All HTML special characters are 7 bit and can be replaced first

+ 20 - 0
functions/page_header.php

@@ -8,10 +8,30 @@
 
    $page_header_php = true;
 
+   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
    header ("Content-Type: text/html; charset=iso-8859-1");
 
+   // Setting the language to use for gettext if it is not English
+   // (the default language) or empty.
+   if (!isset($squirrelmail_language))
+      $squirrelmail_language = getPref ($data_dir, $username, "language");
+
+   if ($squirrelmail_language != "en" && $squirrelmail_language != "") {
+      putenv("LANG=$use_language");
+      bindtextdomain("squirrelmail", "../locale/");
+      textdomain("squirrelmail");
+
+      // Setting cookie to use on the login screen the next time the
+      // same user logs in.
+      if (!isset($HTTP_COOKIE_VARS["squirrelmail_language"]))
+         setcookie("squirrelmail_language", $squirrelmail_language, 
+                   time()+2592000);
+   }
+
    function displayPageHeader($color, $mailbox) {
       /** Here is the header and wrapping table **/
       $shortBoxName = readShortMailboxName($mailbox, ".");

+ 3 - 1
src/load_prefs.php

@@ -1,6 +1,8 @@
 <?
    include("../config/config.php");
-   include("../functions/prefs.php");
+
+   if (!isset($prefs_php))
+      include("../functions/prefs.php");
 
    checkForPrefs($data_dir, $username);
 

+ 6 - 3
src/login.php

@@ -9,14 +9,17 @@
    setcookie("username", "", time(), "/");
    setcookie("key", "", time(), "/");
    setcookie("logged_in", 0, time(), "/");
-?>
-<HTML>
-<?
+
    if (!isset($config_php))
       include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($page_header_php))
+      include("../functions/page_header.php");
 
+?>
+<HTML>
+<?
    echo "<BODY TEXT=000000 BGCOLOR=FFFFFF LINK=0000CC VLINK=0000CC ALINK=0000CC>\n";
  
    // let's check to see if they compiled with gettext support

+ 22 - 0
src/options.php

@@ -11,6 +11,8 @@
       include("../functions/imap.php");
    if (!isset($array_php))
       include("../functions/array.php");
+   if (!isset($i18n_php))
+      include("../functions/i18n.php");
 
    include("../src/load_prefs.php");
 
@@ -26,6 +28,7 @@
    $fullname = getPref($data_dir, $username, "full_name");
    $replyto = getPref($data_dir, $username, "reply_to");
    $email_address  = getPref($data_dir, $username, "email_address");
+   $chosen_language = getPref($data_dir, $username, "language");
 
    echo "<TABLE WIDTH=100% COLS=1 ALIGN=CENTER>\n";
    echo "   <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>\n";
@@ -95,6 +98,25 @@
    echo "         </SELECT></TT>";
    echo "      </TD>";
    echo "   </TR>";
+   // LANGUAGE
+   echo "   <TR>";
+   echo "      <TD WIDTH=20% ALIGN=RIGHT>";
+   echo "         <FONT FACE=\"Arial,Helvetica\">";
+   echo           _("Language:");
+   echo "         </FONT>";
+   echo "      </TD>";
+   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";
+      else
+         echo "         <OPTION VALUE=\"".$languages[$i]["CODE"]."\">".$languages[$i]["NAME"]."\n";
+   }
+   echo "         </SELECT></TT>";
+   echo "      </TD>";
+   echo "   </TR>";
    echo "</TABLE>";
 
 

+ 1 - 0
src/options_submit.php

@@ -24,6 +24,7 @@
    setPref($data_dir, $username, "editor_size", $editorsize);
    setPref($data_dir, $username, "use_signature", $usesignature);
    setPref($data_dir, $username, "left_refresh", $leftrefresh);
+   setPref($data_dir, $username, "language", $language);
 
    setSig($data_dir, $username, stripslashes($signature_edit));