mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Added proxy-functions for Translatable to provide a consistent interface for developers
ENHANCEMENT Explicit attribute-visibility ENHANCEMENT Empty $current_locale by default, get_locale() falls back to $default_locale (avoid duplication) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43657 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
c5ec4314b4
commit
bbe86015d7
@ -9,23 +9,23 @@
|
||||
class i18n extends Controller {
|
||||
|
||||
/**
|
||||
* This static variable is used to store the current defined locale. Default value is 'en_US'
|
||||
* This static variable is used to store the current defined locale.
|
||||
*/
|
||||
static $current_locale = 'en_US';
|
||||
protected static $current_locale = '';
|
||||
|
||||
/**
|
||||
* This is the locale in which generated language files are (we assume US English)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $default_locale = 'en_US';
|
||||
protected static $default_locale = 'en_US';
|
||||
|
||||
/**
|
||||
* An exhaustive list of possible locales (code => language and country)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $all_locales = array(
|
||||
public static $all_locales = array(
|
||||
'aa_DJ' => 'Afar (Djibouti)',
|
||||
'ab_GE' => 'Abkhazian (Georgia)',
|
||||
'abr_GH' => 'Abron (Ghana)',
|
||||
@ -504,7 +504,7 @@ class i18n extends Controller {
|
||||
* A list of commonly used languages, in the form
|
||||
* langcode => array( EnglishName, NativeName)
|
||||
*/
|
||||
static $common_languages = array(
|
||||
public static $common_languages = array(
|
||||
'af' => array('Afrikaans', 'Afrikaans'),
|
||||
'sq' => array('Albanian', 'shqip'),
|
||||
'ar' => array('Arabic', 'العربية'),
|
||||
@ -1052,10 +1052,26 @@ class i18n extends Controller {
|
||||
* @return string Current locale in the system
|
||||
*/
|
||||
static function get_locale() {
|
||||
return self::$current_locale;
|
||||
return (!empty(self::$current_locale)) ? self::$current_locale : self::$default_locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default language (proxy for Translatable::set_default_lang())
|
||||
*
|
||||
* @param $lang String
|
||||
*/
|
||||
static function set_default_lang($lang) {
|
||||
Translatable::set_default_lang($lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default language (proxy for Translatable::default_lang())
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
static function default_lang() {
|
||||
return Translatable::default_lang();
|
||||
}
|
||||
|
||||
/**
|
||||
* Include a locale file determined by module name and locale
|
||||
|
Loading…
x
Reference in New Issue
Block a user