* More minor changes
[squirrelmail.git] / functions / i18n.php
index 3aec6c9c6cd9ccde75f75cca43e85369a696ff9e..0c30fa19efad4f57ab166eb2433ee9c98fe06eaa 100644 (file)
    global $use_gettext;
    
    // Detect whether gettext is installed.
-   // If it is, set the flag so we can use it.
-   if (! function_exists('_') || 
-       ! function_exists('bindtextdomain') ||
-       ! function_exists('textdomain'))
-       $use_gettext = false;
-   else
-       $use_gettext = true;
-          
-
-   // Avoid warnings/errors if gettext is not installed
-   if (! function_exists('_')) {
-      function _($str) { return $str; };
-   }
-   if (! function_exists('bindtextdomain')) {
-      function bindtextdomain() { return; }
-   }
-   if (! function_exists('textdomain')) {
-      function textdomain() { return; }
+   $gettext_flags = 0;
+   if (function_exists('_')) $gettext_flags += 1;
+   if (function_exists('bindtextdomain')) $gettext_flags += 2;
+   if (function_exists('textdomain')) $gettext_flags += 4;
+
+   // If gettext is fully loaded, cool
+   if ($gettext_flags == 7)
+      $use_gettext = true;
+   // If we can fake gettext, try that
+   elseif ($gettext_flags == 0) {
+      $use_gettext = true;
+      include('../functions/gettext.php');
+   } else {
+      // Uh-ho.  A weird install
+      if (! $gettext_flags & 1) {
+         function _($str) { return $str; };
+      }
+      if (! $gettext_flags & 2) {
+         function bindtextdomain() { return; }
+      }
+      if (! $gettext_flags & 4) {
+         function textdomain() { return; }
+      }
    }
 
 
       
       if ($SetupAlready)
          return;
-        
+
       $SetupAlready = 1;
       
       $charset_headers_sent=false;
       }
 
       if (isset($sm_language) && $use_gettext &&
-         $squirrelmail_language != '' &&
-        isset($languages[$sm_language]['CHARSET'])) {
+          $squirrelmail_language != '' &&
+         isset($languages[$sm_language]['CHARSET'])) {
          if ((ini_get('safe_mode') == FALSE) && (getenv('LC_ALL') != $sm_language)) {
            putenv('LC_ALL=' . $sm_language);
          }
          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(){