Changeset 1569

Show
Ignore:
Timestamp:
09/10/06 11:52:49 (2 years ago)
Author:
mbonetti
Message:

Locale selection in the admin, LC_ALL

Location:
trunk/gregarius
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/admin/config.php

    r1561 r1569  
    298298        case 'rss.output.lang': 
    299299            $langs = getLanguages(); 
     300 
    300301            $codes = array_keys($langs); 
    301302            $out_val = implode(',',$codes); 
  • trunk/gregarius/admin/index.php

    r1561 r1569  
    258258    $ret = array(); 
    259259    $activeIdx = "0"; 
     260    $ret['en_US']='en_US'; 
    260261    while (false !== ($entry = $d->read())) { 
    261         if ( 
    262             $entry != "CVS" && 
    263             substr($entry,0,1) != "." 
    264         ) { 
    265             $info = getLanguageInfo($entry); 
    266             if (count($info) && array_key_exists('language',$info)) { 
    267                 $shortL=  preg_replace('|\.php.*$|','',$entry); 
    268                 $ret[$shortL] = $info['language']; 
    269             } 
    270         } 
     262        if (preg_match('#^[a-z]{2}_[A-Z]{2}$#',$entry)) { 
     263            $ret[$entry]=$entry; 
     264        }  
    271265    } 
    272266    $d->close(); 
  • trunk/gregarius/cls/l10n.php

    r1479 r1569  
    3535     
    3636    function RSSl10n($locale) { 
     37        $locale = preg_replace('#[^a-zA-Z_]#','',$locale); 
     38        if (function_exists('version_compare') && version_compare("4.2.0",PHP_VERSION, "<=") && preg_match('#([a-z]{2})_([A-Z]{2})#',$locale,$m)) { 
     39            $locales=array( 
     40                $m[0].'UTF-8', 
     41                $m[0].'utf-8', 
     42                $m[0], 
     43                $m[1].'_'.strtoupper($m[1]), 
     44                $m[1], 
     45                $m[2] 
     46            ); 
     47            setlocale(LC_ALL, $locales);     
     48        } else { 
     49            setlocale(LC_ALL, $locale); 
     50        } 
     51         
    3752        $path = GREGARIUS_HOME .'/intl/' . $locale . '/LC_MESSAGES/messages.mo'; 
    3853        $streamer = new FileReader($path); 
  • trunk/gregarius/init.php

    r1564 r1569  
    115115// Localization 
    116116// 
    117 require_once('cls/l10n.php'); 
    118 $GLOBALS['rssl10n'] = new RSSl10n(); 
    119  
    120  
    121117$lang = getConfig('rss.output.lang'); 
    122118if (!preg_match('#^[a-zA-Z_]+$#', $lang)) { 
    123119    die('woopsie, bad lang: ' .$lang); 
    124120} 
     121 
     122require_once('cls/l10n.php'); 
     123$GLOBALS['rssl10n'] = new RSSl10n($lang); 
     124 
     125 
    125126 
    126127if ($lang && file_exists(dirname(__FILE__) . "/" . "intl/$lang.php")) { 
     
    146147} 
    147148 
    148  
     149/* 
    149150// Load the right locale 
    150151if (defined('OVERRIDE_LOCALE')) { 
     
    166167    } 
    167168} 
    168  
     169*/ 
    169170 
    170171