Browse Source

Things should now work even if PHP is compiled without gettext support.

gustavf 25 years ago
parent
commit
3e8621f4c9
2 changed files with 33 additions and 25 deletions
  1. 19 12
      functions/page_header.php
  2. 14 13
      src/login.php

+ 19 - 12
functions/page_header.php

@@ -15,18 +15,25 @@
    // 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.
-   $squirrelmail_language = getPref ($data_dir, $username, "language");
-   if ($squirrelmail_language != "en" && $squirrelmail_language != "") {
-      putenv("LANG=$squirrelmail_language");
-      bindtextdomain("squirrelmail", "../locale/");
-      textdomain("squirrelmail");
-
-      // Setting cookie to use on the login screen the next time the
-      // same user logs in.
-      setcookie("squirrelmail_language", $squirrelmail_language, 
-                time()+2592000);
+   // Check to see if gettext is installed
+   if (function_exists("_")) {
+      // Setting the language to use for gettext if it is not English
+      // (the default language) or empty.
+      $squirrelmail_language = getPref ($data_dir, $username, "language");
+      if ($squirrelmail_language != "en" && $squirrelmail_language != "") {
+         putenv("LANG=$squirrelmail_language");
+         bindtextdomain("squirrelmail", "../locale/");
+         textdomain("squirrelmail");
+         
+         // Setting cookie to use on the login screen the next time the
+         // same user logs in.
+         setcookie("squirrelmail_language", $squirrelmail_language, 
+                   time()+2592000);
+      }
+   } else {
+      function _($string) {
+         return $string;
+      }
    }
 
    function displayPageHeader($color, $mailbox) {

+ 14 - 13
src/login.php

@@ -15,13 +15,20 @@
    if (!isset($strings_php))
       include("../functions/strings.php");
 
-   // $squirrelmail_language is set by a cookie when the user selects
-   // language
-   if (isset($squirrelmail_language)) {
-      if ($squirrelmail_language != "en") {
-         putenv("LANG=".$squirrelmail_language);
-         bindtextdomain("squirrelmail", "../locale/");
-         textdomain("squirrelmail");
+   // let's check to see if they compiled with gettext support
+   if (!function_exists("_")) {
+      function _($string) {
+         return $string;
+      }
+   } else {
+      // $squirrelmail_language is set by a cookie when the user selects
+      // language
+      if (isset($squirrelmail_language)) {
+         if ($squirrelmail_language != "en") {
+            putenv("LANG=".$squirrelmail_language);
+            bindtextdomain("squirrelmail", "../locale/");
+            textdomain("squirrelmail");
+         }
       }
    }
 
@@ -31,12 +38,6 @@
    echo "</TITLE></HEAD>\n";
    echo "<BODY TEXT=000000 BGCOLOR=FFFFFF LINK=0000CC VLINK=0000CC ALINK=0000CC>\n";
  
-   // let's check to see if they compiled with gettext support
-   if (!function_exists("_")) {
-      echo "<CENTER>PHP was not configured --with-gettext.  Reconfigure and try again.</CENTER></BODY></HTML>";
-      exit;
-   }
-   
    echo "<FORM ACTION=webmail.php METHOD=\"POST\" NAME=f>\n";
    echo "<CENTER><IMG SRC=\"$org_logo\"</CENTER>\n";
    echo "<CENTER><SMALL>";