From bbe86015d74591610ba8fa40477b3801d4c9b1d3 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 21 Oct 2007 00:50:31 +0000 Subject: [PATCH] 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 --- core/i18n.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/core/i18n.php b/core/i18n.php index 5a8ca7cc1..d99bf3d29 100755 --- a/core/i18n.php +++ b/core/i18n.php @@ -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