commit please

Anton Nehoroshih anton@valuehost.ru
Wed, 8 Aug 2001 15:39:01 +0400


Opss sorry this correct patch

Patch for internation charset


Index: horde/lib/MIME/Message.php
===================================================================
RCS file: /cvs/horde/horde/lib/MIME/Message.php,v
retrieving revision 1.5
diff -u -c -r1.5 Message.php
*** horde/lib/MIME/Message.php  2001/01/19 03:39:06     1.5
--- horde/lib/MIME/Message.php  2001/08/08 09:44:31
***************
*** 62,68 ****
       */
      function encode($headers)
      {
!         global $HTTP_ACCEPT_CHARSET;
          
          if (!empty($HTTP_ACCEPT_CHARSET)) {
              $charsets = explode(',', $HTTP_ACCEPT_CHARSET);
--- 62,68 ----
       */
      function encode($headers)
      {
!         global $HTTP_ACCEPT_CHARSET,$conf;
          
          if (!empty($HTTP_ACCEPT_CHARSET)) {
              $charsets = explode(',', $HTTP_ACCEPT_CHARSET);
***************
*** 70,76 ****
                  $charset = trim($charsets[0]);
              }
          }
!         if (empty($charset)) $charset = 'ISO-8859-1';
          
          foreach ($headers as $key => $val) {
              if ($key == 'To' || $key == 'Cc' || $key == 'Bcc' || $key == 'From') {
--- 70,82 ----
                  $charset = trim($charsets[0]);
              }
          }
!         if (empty($charset)) {
!           if(empty($conf['lang']['charset'])) {
!               $charset = 'ISO-8859-1';
!           } else {
!               $charset = $conf['lang']['charset'];
!           }
!       } 
          
          foreach ($headers as $key => $val) {
              if ($key == 'To' || $key == 'Cc' || $key == 'Bcc' || $key == 'From') {
Index: horde/lib/MIME/Part.php
===================================================================
RCS file: /cvs/horde/horde/lib/MIME/Part.php,v
retrieving revision 1.7
diff -u -c -r1.7 Part.php
*** horde/lib/MIME/Part.php     2001/07/05 20:10:46     1.7
--- horde/lib/MIME/Part.php     2001/08/08 09:44:31
***************
*** 170,175 ****
--- 170,176 ----
       */
      function setEncoding()
      {
B+      global $conf;
          $text = str_replace("\n", ' ', $this->contents);
          // FIXME: dependancy on IMAP module
          if ($this->type == 'text'
***************
*** 188,194 ****
                  }
              }
              
!             if (empty($this->charset)) $charset = 'ISO-8859-1';
          }
      }
      
--- 189,201 ----
                  }
              }
              
!             if (empty($this->charset)) {
!               if(empty($conf['lang']['charset'])) {
!                   $charset = 'ISO-8859-1';
!               } else {
!                   $charset = $conf['lang']['charset'];
!               }
!           } 
          }
      }



>From jrkuipers@lauwerscollege.nl Date: Wed,  8 Aug 2001 14:17:00 +0200
Return-Path: <jrkuipers@lauwerscollege.nl>
Mailing-List: contact dev-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list dev@lists.horde.org
Received: (qmail 79801 invoked from network); 8 Aug 2001 12:17:33 -0000
Received: from c3207.upc-c.chello.nl (HELO linux.lauwerscollege.nl) (212.187.3.207)
  by horde.org with SMTP; 8 Aug 2001 12:17:33 -0000
Received: (from www@localhost)
	by linux.lauwerscollege.nl (8.9.3/8.8.7) id OAA32270
	for dev@lists.horde.org; Wed, 8 Aug 2001 14:17:01 +0200
Received: from 212.187.3.207 ( [212.187.3.207])
	as user jrkuipers@localhost by webmail.lauwerscollege.nl with HTTP;
	Wed,  8 Aug 2001 14:17:00 +0200
Message-ID: <997273020.3b712dbcdea99@webmail.lauwerscollege.nl>
Date: Wed,  8 Aug 2001 14:17:00 +0200
From: Jan Kuipers <jrkuipers@lauwerscollege.nl>
To: dev@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 2.3.7-cvs
Subject: Languagedetection/cookie problems 

Hello,

I discovered some problems with the language detection in /horde/lib/Lang.php. When a LL_CC (gettext) language notation is used in /horde/config/lang.php the
proper language can't be detected, because the browser returns a two-letter
languagecode. In that case the defaultlanguage should be used, but the $conf
variable is NOT set in this stage!! In this case a cookie will NOT be set!
There are two circumstances when this occurs: 1. When using the LL_CC notation.
2. When the browser doesn't support the HTTP_ACCEPT_LANGUAGE variable (Opera).

In case of the languagedetection I use the following solution:

horde/lib/Lang.php.diff

-----------<snip>--------
--- Lang.php	Thu Apr 26 22:14:12 2001
+++ -	Wed Aug  8 13:36:36 2001
@@ -44,10 +44,10 @@
             foreach ($browser_langs as $lang) {
                 $lang = trim($lang);
                 if (Lang::isValid($lang)) {
-                    $language = $lang;
+                    $language = $GLOBALS['nls']['browser_languages'][$lang];
                     break;
                 } elseif (Lang::isValid(substr($lang, 0, 2))) {
-                    $language = substr($lang, 0, 2);
+                    $language = $GLOBALS['nls']['browser_languages'][$lang];
                     break;
                 }
             }
@@ -75,7 +75,7 @@
      */
     function isValid($language)
     {
-        return !empty($GLOBALS['nls']['languages'][$language]);
+        return !empty($GLOBALS['nls']['languages'][$language]) || !empty($GLOBALS['nls']['browser_languages'][$language]);
     }
     
 }
--------------<snip>-----------

horde/config/lang.php (example)

--------------<snip>-----------
<?php

/* Languages configuration file
 *
 * $Horde: horde/config/lang.php.dist,v 1.2 2001/07/17 14:22:20 chuck Exp $
 */

// Horde languages
$nls['languages']['zh_CN'] = 'Chinese (Simplified)';
$nls['languages']['zh_TW'] = 'Chinese (Traditional)';
$nls['languages']['de'] = 'Deutsch';
$nls['languages']['en'] = 'English';
$nls['languages']['es'] = 'Espaņol';
$nls['languages']['fr'] = 'Fran&ccedil;ais';
$nls['languages']['nl_NL'] = 'Nederlands';
$nls['languages']['no_BOK'] = 'Norsk bokm&aring;l';
$nls['languages']['pt_BR'] = 'Portugu&ecirc;s Brasileiro';
$nls['languages']['uk'] = 'Ukranian';

//Detected browser languages
$nls['browser_languages']['nl'] = 'nl_NL';
$nls['browser_languages']['en'] = 'en';
$nls['browser_languages']['de'] = 'de';
$nls['browser_languages']['fr'] = 'fr';

// charsets
$nls['charsets']['cs'] = 'ISO-8859-2';
$nls['charsets']['el'] = 'ISO-8859-7';
$nls['charsets']['kr'] = 'EUC-KR';
$nls['charsets']['zh_CN'] = 'GB2312';
$nls['charsets']['zh_TW'] = 'Big5';

// multi-language spelling support
$nls['spelling']['cs'] = '-T latin2 -d czech';
$nls['spelling']['da'] = '-T latin1 -d dansk';
$nls['spelling']['de'] = '-T latin1 -d deutsch';
$nls['spelling']['en'] = '-d english';
$nls['spelling']['es'] = '-d espanol';
$nls['spelling']['fr'] = '-d francais';
$nls['spelling']['it'] = '-T latin1 -d italian';
$nls['spelling']['nl_NL'] = '-d nederlands';
$nls['spelling']['no_NYN'] = '-d norsk';
$nls['spelling']['pl'] = '-d polish';
$nls['spelling']['se'] = '-d svenska';
$nls['spelling']['ru'] = '-d russian';

$GLOBALS['nls'] = &$nls;

?>
---------------<snip>-------------

Undoubtedly there are better ways in handling this problem ;)

The problem with the defaultlanguage isn't solved yet.

--
Jan Kuipers,
Systeembeheer Lauwers College