Show
Ignore:
Timestamp:
09/25/06 14:33:50 (2 years ago)
Author:
mbonetti
Message:

fixed a stupid bug where some locales from $_SERVERHTTP_ACCEPT_LANGUAGE?
were not handled.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/cls/l10n.php

    r1589 r1591  
    7979    function __detectUserLang() { 
    8080       if (isset($_REQUEST['lang']) && preg_match('#^[a-z]{2}_?([A-Z]{2})?$#',$_REQUEST['lang']) && ($_REQUEST['lang'] == 'en' || file_exists(GREGARIUS_HOME .'intl/'.$_REQUEST['lang']))) { 
    81             setcookie(RSS_LOCALE_COOKIE,$_REQUEST['lang'],time()+3600*6,getPath()); 
     81            $this -> __setLocaleCookie($_REQUEST['lang']); 
    8282            return  $_REQUEST['lang']; 
    8383        } elseif (isset($_COOKIE[RSS_LOCALE_COOKIE])) { 
     
    9696                if (preg_match('#^([a-z]{2})[\-_]?([a-z]{2})?$#i',$ll,$pm)) { 
    9797                    $ret =null; 
    98                     if (isset($pm[2])){ 
    99                         if (file_exists(GREGARIUS_HOME .'intl/'.$pm[1] ."_".strtoupper($pm[2]))) { 
    100                             // xx-yy -> xx_YY 
    101                             $ret= $pm[1] ."_".strtoupper($pm[2]); 
    102                         } 
     98                    if (isset($pm[2]) && file_exists(GREGARIUS_HOME .'intl/'.$pm[1] ."_".strtoupper($pm[2]))) { 
     99                        // xx-yy -> xx_YY 
     100                        $ret= $pm[1] ."_".strtoupper($pm[2]); 
    103101                    } elseif(file_exists(GREGARIUS_HOME .'intl/'.$pm[1] )) { 
    104102                        // xx  -> xx 
     
    111109                    if ($ret) { 
    112110                        // remember the detected locale for a couple hours 
    113                         setcookie(RSS_LOCALE_COOKIE,$ret,time()+3600*6,getPath()); 
     111                        $this -> __setLocaleCookie($ret); 
    114112                        return $ret; 
    115113                    } 
     
    121119        return getConfig('rss.output.lang'); 
    122120    } 
     121 
     122    function __setLocaleCookie($value) { 
     123        setcookie(RSS_LOCALE_COOKIE,$value,time()+3600*6,getPath()); 
     124    } 
    123125} 
    124126