Browse Source

rename I18n::environmentLocale to I18n::defaultLocale

This better reflects woat the method/property means - it's the locale
before the application did anything
AD7six 11 years ago
parent
commit
8b764b25a6

+ 6 - 6
src/I18n/I18n.php

@@ -41,7 +41,7 @@ class I18n {
  *
  *
  * @var string
  * @var string
  */
  */
-	protected static $_environmentLocale;
+	protected static $_defaultLocale;
 
 
 /**
 /**
  * Returns the translators collection instance. It can be used
  * Returns the translators collection instance. It can be used
@@ -203,7 +203,7 @@ class I18n {
  * @return string|null The name of the default locale.
  * @return string|null The name of the default locale.
  */
  */
 	public static function locale($locale = null) {
 	public static function locale($locale = null) {
-		static::environmentLocale();
+		static::defaultLocale();
 
 
 		if (!empty($locale)) {
 		if (!empty($locale)) {
 			Locale::setDefault($locale);
 			Locale::setDefault($locale);
@@ -227,11 +227,11 @@ class I18n {
  *
  *
  * @return string
  * @return string
  */
  */
-	public static function environmentLocale() {
-		if (static::$_environmentLocale === null) {
-			static::$_environmentLocale = Locale::getDefault() ?: 'en_US';
+	public static function defaultLocale() {
+		if (static::$_defaultLocale === null) {
+			static::$_defaultLocale = Locale::getDefault() ?: 'en_US';
 		}
 		}
-		return static::$_environmentLocale;
+		return static::$_defaultLocale;
 	}
 	}
 
 
 /**
 /**

+ 1 - 1
src/Model/Behavior/TranslateBehavior.php

@@ -75,7 +75,7 @@ class TranslateBehavior extends Behavior {
  * @param array $config The config for this behavior.
  * @param array $config The config for this behavior.
  */
  */
 	public function __construct(Table $table, array $config = []) {
 	public function __construct(Table $table, array $config = []) {
-		$config += ['defaultLocale' => I18n::environmentLocale()];
+		$config += ['defaultLocale' => I18n::defaultLocale()];
 		parent::__construct($table, $config);
 		parent::__construct($table, $config);
 
 
 		$this->_table = $table;
 		$this->_table = $table;

+ 1 - 1
tests/TestCase/Model/Behavior/TranslateBehaviorTest.php

@@ -41,7 +41,7 @@ class TranslateBehaviorTest extends TestCase {
 
 
 	public function tearDown() {
 	public function tearDown() {
 		parent::tearDown();
 		parent::tearDown();
-		I18n::locale(I18n::environmentLocale());
+		I18n::locale(I18n::defaultLocale());
 		TableRegistry::clear();
 		TableRegistry::clear();
 	}
 	}