Changeset 2433

Show
Ignore:
Timestamp:
09/02/08 16:19:23 (3 months ago)
Author:
moeffju
Message:

Add an option to set the system locale to use.
This is preliminary and should probably be replaced by a setting in the chosen language file.

Location:
trunk/htdocs
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/index.php

    r2396 r2433  
    170170} 
    171171 
     172if ( @ Options::get( 'system_locale' ) ) { 
     173    Locale::set_system_locale( Options::get( 'system_locale' ) ); 
     174} 
     175 
    172176// Verify if the database has to be upgraded. 
    173177if ( Version::requires_upgrade() ) { 
  • trunk/htdocs/system/classes/adminhandler.php

    r2432 r2433  
    210210                'selectarray' => array_merge( array( '' => 'default' ), array_combine( Locale::list_all(), Locale::list_all() ) ), 
    211211                'helptext' => 'International language code', 
    212             ) 
     212            ), 
     213            'system_locale' => array( 
     214                'label' => _t('System Locale'), 
     215                'type' => 'text', 
     216                'helptext' => 'The appropriate locale code for your server', 
     217            ), 
    213218        ); 
    214219 
  • trunk/htdocs/system/classes/locale.php

    r2427 r2433  
    2828        self::$locale= strtolower( $locale ); 
    2929        self::$uselocale= self::load_domain( 'habari' ); 
     30    } 
     31     
     32    /** 
     33     * Set system locale. 
     34     * 
     35     * The problem is that every platform has its own way to designate a locale, 
     36     * so for German you could have 'de', 'de_DE', 'de_DE.UTF-8', 'de_DE.UTF-8@euro' 
     37     * (Linux) or 'DEU' (Windows), etc. 
     38     * 
     39     * @todo: This setting should probably be stored in the language files. 
     40     * 
     41     * @param string... $locale The locale(s) to set. They will be tried in order. 
     42     * @return string the locale that was picked, or FALSE if an error occurred 
     43     */ 
     44    public static function set_system_locale() 
     45    { 
     46        if ( func_num_args() == 0 ) return; 
     47        $args= func_get_args(); 
     48        array_unshift( $args, LC_ALL ); 
     49         
     50        return call_user_func_array( 'setlocale', $args ); 
    3051    } 
    3152