Show
Ignore:
Timestamp:
09/17/06 12:12:16 (2 years ago)
Author:
mbonetti
Message:
 
Files:
1 modified

Legend:

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

    r1584 r1586  
    3838    function RSSl10n() { 
    3939        $this -> locale = preg_replace('#[^a-zA-Z_]#','',$this -> __detectUserLang()); 
    40          
    41         $ll=explode('_',$this -> locale); 
    42         $this->isloang=$ll[0].'-'.strtoupper($ll[1]); 
    43          
    44         if (function_exists('version_compare') && version_compare("4.3.0",PHP_VERSION, "<=") && preg_match('#([a-z]{2})_([A-Z]{2})#',$this -> locale,$m)) { 
     40        $this -> isolang=str_replace('_','-',$this -> locale); 
     41        if (function_exists('version_compare') && version_compare("4.3.0",PHP_VERSION, "<=") && preg_match('#([a-z]{2})_?([A-Z]{2})?#',$this -> locale,$m)) { 
    4542            $locales=array( 
    46                 $m[0].'UTF-8', 
    47                 $m[0].'utf-8', 
     43                $m[0].'.UTF-8', 
     44                $m[0].'.utf-8', 
    4845                $m[0], 
    49                 $m[1].'_'.strtoupper($m[1]), 
    50                 $m[1], 
    51                 $m[2] 
     46                $m[1],               
     47                $m[1].'_'.strtoupper($m[1]) 
     48                //$m[2] 
    5249            ); 
    5350            setlocale(LC_ALL, $locales);     
     
    8178     */ 
    8279    function __detectUserLang() { 
    83        if (isset($_REQUEST['lang']) && preg_match('#^[a-z]{2}_[A-Z]{2}$#',$_REQUEST['lang']) && file_exists(GREGARIUS_HOME .'intl/'.$_REQUEST['lang'])) { 
     80       if (isset($_REQUEST['lang']) && preg_match('#^[a-z]{2}_?([A-Z]{2})?$#',$_REQUEST['lang']) && file_exists(GREGARIUS_HOME .'intl/'.$_REQUEST['lang'])) { 
    8481            setcookie(RSS_LOCALE_COOKIE,$_REQUEST['lang'],time()+3600*6,getPath()); 
    8582            return  $_REQUEST['lang']; 
     
    103100                            // xx-yy -> xx_YY 
    104101                            $ret= $pm[1] ."_".strtoupper($pm[2]); 
    105                         } elseif(file_exists(GREGARIUS_HOME .'intl/'.$pm[1] ."_".strtoupper($pm[1]))) { 
    106                             // xx-yy -> xx_XX 
    107                             $ret= $pm[1] ."_".strtoupper($pm[1]); 
    108102                        } 
    109                     } elseif(file_exists(GREGARIUS_HOME .'intl/'.$pm[1] ."_".strtoupper($pm[1]))) { 
    110                         // xx  -> xx_XX 
    111                         $ret= $pm[1] ."_".strtoupper($pm[1]); 
     103                    } elseif(file_exists(GREGARIUS_HOME .'intl/'.$pm[1] )) { 
     104                        // xx  -> xx 
     105                        $ret= $pm[1]; 
    112106                    } elseif($pm[1] == 'en') { 
    113107                        // ugly: a better way would be to look up all the available locales