** -> *
[squirrelmail.git] / functions / i18n.php
index cc773d3b9e900dbcba14e4574e2298945586ad64..2ce457b1f144020b2dfb771ae0a6f10a29749d50 100644 (file)
@@ -1,20 +1,19 @@
 <?php
 
-/**
- ** i18n.php
- ** 
- ** This file contains variuos functions that are needed to do
- ** internationalization of SquirrelMail.
- **
- ** Internally the output character set is used. Other characters are
- ** encoded using Unicode entities according to HTML 4.0.
- **
- ** $Id$
- **/
-
-   if (defined ('i18n_php'))
-      return; 
-   define ('i18n_php', true);
+   /**
+    *  i18n.php
+    *
+    *   Copyright (c) 1999-2001 The Squirrelmail Development Team
+    *   Licensed under the GNU GPL. For full terms see the file COPYING.
+    *
+    *  This file contains variuos functions that are needed to do
+    *  internationalization of SquirrelMail.
+    *
+    *  Internally the output character set is used. Other characters are
+    *  encoded using Unicode entities according to HTML 4.0.
+    *
+    *  $Id$
+    */
 
    global $squirrelmail_language, $languages;
    if (! isset($squirrelmail_language)) { $squirrelmail_language = ''; }
    $languages['ca']['CHARSET'] = 'iso-8859-1';
    $languages['ca_CA']['ALIAS'] = 'ca';
 
+   /* PLEASE DON'T TOUCH!!!
+    * Correct locale name, which should be set by setlocale and/or putenv('LC_ALL='...)
+    * is 'cs_CZ' and NOT 'cs', this applies to all locale names, look into docs, if you
+    * don't believe me.  Ondrej Sury, czech and slovak translator.
+    */
    $languages['cs_CZ']['NAME']    = 'Czech';
    $languages['cs_CZ']['CHARSET'] = 'iso-8859-2';
+   $languages['cs']['ALIAS']      = 'cs_CZ';
+   $languages['cz']['ALIAS']      = 'cs_CZ'; // set up by some ancient versions of IE
    
    $languages['da']['NAME']    = 'Danish';
    $languages['da']['CHARSET'] = 'iso-8859-1';
    $languages['es']['CHARSET'] = 'iso-8859-1';
    $languages['es_ES']['ALIAS'] = 'es';
 
+   $languages['et']['NAME']    = 'Estonian';
+   $languages['et']['CHARSET'] = 'iso-8859-15';
+   $languages['et_EE']['ALIAS'] = 'et';
+
    $languages['fi']['NAME']    = 'Finnish';
    $languages['fi']['CHARSET'] = 'iso-8859-1';
    $languages['fi_FI']['ALIAS'] = 'fi';
    $languages['sv']['CHARSET'] = 'iso-8859-1';
    $languages['sv_SV']['ALIAS'] = 'sv';
    
+   $languages['tr']['NAME']    = 'Turkish';
+   $languages['tr']['CHARSET'] = 'iso-8859-9';
+   $languages['tr_TR']['ALIAS'] = 'tr';
+   
    $languages['tw']['NAME']    = 'Taiwan';
    $languages['tw']['CHARSET'] = 'big5';
    $languages['tw_TW']['ALIAS'] = 'tw';
    
+   $languages['sk_SK']['NAME']     = 'Slovak';
+   $languages['sk_SK']['CHARSET']  = 'iso-8859-2';
+   $languages['sk']['ALIAS']       = 'sk_SK';
+   
+   $languages['ro']['NAME']    = 'Romanian';
+   $languages['ro']['CHARSET'] = 'iso-8859-2';
+   $languages['ro_RO']['ALIAS'] = 'ro';
+
+   $languages['th']['NAME']    = 'Thai';
+   $languages['th']['CHARSET'] = 'tis-620';
+
+   $languages['lt']['NAME']    = 'Lithuanian';
+   $languages['lt']['CHARSET'] = 'iso-8859-13';
+   $languages['lt_LT']['ALIAS'] = 'lt';
+
+   $languages['sl']['NAME']    = 'Slovenian';
+   $languages['sl']['CHARSET'] = 'iso-8859-2';
+
+   $languages['bg']['NAME']    = 'Bulgarian';
+   $languages['bg']['CHARSET'] = 'iso-8859-1';
 
    // Decodes a string to the internal encoding from the given charset
    function charset_decode ($charset, $string) {
          return charset_decode_ns_4551_1 ($string);
       } else if ($charset == 'koi8-r') {
         return charset_decode_koi8r ($string);
+      } else if ($charset == 'windows-1251') {
+        return charset_decode_koi8r ($string);
       } else
          return $string;
    }
       // Only do the slow convert if there are 8-bit characters
       if (! ereg("[\200-\377]", $string))
          return $string;
-        
+         
       // NO-BREAK SPACE
       $string = str_replace("\240", '&#160;', $string);
       // LATIN CAPITAL LETTER A WITH OGONEK
 
       if (strtolower($default_charset) == 'iso-8859-7')
          return $string;
-        
+         
       // Only do the slow convert if there are 8-bit characters
       if (!ereg("[\200-\377]", $string))
          return $string;
-        
+         
       // Some diverse characters in the beginning
       $string = str_replace("\240", '&#160;', $string);
       $string = str_replace("\241", '&#8216;', $string);
       // These are Unicode 900-902
       while (ereg("([\270-\272])", $string, $res)) {
          $replace = '&#' . (ord($res[1])+720) . ";";
-        $string = str_replace($res[1], $replace, $string);
+         $string = str_replace($res[1], $replace, $string);
       }
          
       // 11/11 (0xBB) Right angle quotation mark is the same as in
       // And now the rest of the charset
       while (ereg("([\274-\376])", $string, $res)) {
          $replace = '&#' . (ord($res[1])+720) . ';';
-        $string = str_replace($res[1], $replace, $string);
+         $string = str_replace($res[1], $replace, $string);
       }
 
       return $string;
 
       if ($default_charset == 'koi8-r')
          return $string;
-        
+         
       // Convert to Unicode HTML entities.
       // This code is rather ineffective.
       $string = str_replace("\200", '&#9472;', $string);
    // If we can fake gettext, try that
    elseif ($gettext_flags == 0) {
       $use_gettext = true;
-      include('../functions/gettext.php');
+      include_once('../functions/gettext.php');
    } else {
       // Uh-ho.  A weird install
       if (! $gettext_flags & 1) {
    // Set up the language to be output
    // if $do_search is true, then scan the browser information
    // for a possible language that we know
-   function set_up_language($sm_language, $do_search = false)
-   {
+   function set_up_language($sm_language, $do_search = false) {
       static $SetupAlready = 0;
       global $HTTP_ACCEPT_LANGUAGE, $use_gettext, $languages, 
           $squirrelmail_language, $squirrelmail_default_language, 
-         $sm_notAlias;
+          $sm_notAlias;
       
       if ($SetupAlready)
          return;
       if ($do_search && ! $sm_language && isset($HTTP_ACCEPT_LANGUAGE)) {
          $sm_language = substr($HTTP_ACCEPT_LANGUAGE, 0, 2);
       }
-      if (! $sm_language && isset($squirrelmail_default_language))
-         $sm_language = $squirrelmail_default_language;
+      if (!$sm_language && isset($squirrelmail_default_language))
+         $squirrelmail_language = $squirrelmail_default_language;
       $sm_notAlias = $sm_language;
       while (isset($languages[$sm_notAlias]['ALIAS']))
          $sm_notAlias = $languages[$sm_notAlias]['ALIAS'];
 
       if (isset($sm_language) && $use_gettext &&
-          $squirrelmail_language != '' &&
-         isset($languages[$sm_notAlias]['CHARSET'])) {
+          $sm_language != '' &&
+          isset($languages[$sm_notAlias]['CHARSET'])) {
          if ((ini_get('safe_mode') == FALSE) && (getenv('LC_ALL') != $sm_language)) {
            putenv('LC_ALL=' . $sm_notAlias);
          }
          setlocale('LC_ALL', $sm_notAlias);
          bindtextdomain('squirrelmail', '../locale/');
          textdomain('squirrelmail');
-         header ('Content-Type: text/html; charset=' . $languages[$sm_language]['CHARSET']);
+         header ('Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET']);
       }
    }
 
      if ($my_charset) $default_charset=$my_charset;
    }
 
-?>
+?>
\ No newline at end of file