Skip to content
Permalink
Browse files

rename I18n::defaultLocale to I18n::locale

there's only ever one locale in play
  • Loading branch information...
AD7six committed Sep 19, 2014
1 parent 8df31b0 commit 78e6420b79569281f12f59b49c7202c8c73c73f5
@@ -66,13 +66,13 @@ public static function translators() {
},
]),
new TranslatorFactory,
static::defaultLocale()
static::locale()
);
}
/**
* Returns an instance of a translator that was configured for the name and passed
* locale. If no locale is passed then it takes the value returned by the `defaultLocale()` method.
* locale. If no locale is passed then it takes the value returned by the `locale()` method.
*
* This method can be used to configure future translators, this is achieved by passing a callable
* as the last argument of this function.
@@ -113,7 +113,7 @@ public static function translators() {
public static function translator($name = 'default', $locale = null, callable $loader = null) {
if ($loader !== null) {
$packages = static::translators()->getPackages();
$locale = $locale ?: static::defaultLocale();
$locale = $locale ?: static::locale();
if ($name !== 'default') {
$loader = function() use ($loader) {
@@ -197,12 +197,12 @@ public static function config($name, callable $loader) {
* This also affects the `intl.default_locale` PHP setting.
*
* When called with no arguments it will return the currently configure
* defaultLocale as stored in the `intl.default_locale` PHP setting.
* locale as stored in the `intl.default_locale` PHP setting.
*
* @param string $locale The name of the locale to set as default.
* @return string|null The name of the default locale.
*/
public static function defaultLocale($locale = null) {
public static function locale($locale = null) {
static::environmentLocale();
if (!empty($locale)) {
@@ -234,7 +234,7 @@ public function afterSave(Event $event, Entity $entity) {
*/
public function locale($locale = null) {
if ($locale === null) {
return $this->_locale ?: I18n::defaultLocale();
return $this->_locale ?: I18n::locale();
}
return $this->_locale = (string)$locale;
}
@@ -40,7 +40,7 @@ class I18nTest extends TestCase {
*/
public function setUp() {
parent::setUp();
$this->locale = I18n::defaultLocale();
$this->locale = I18n::locale();
}
/**
@@ -52,7 +52,7 @@ public function tearDown() {
parent::tearDown();
I18n::clear();
I18n::defaultFormatter('default');
I18n::defaultLocale($this->locale);
I18n::locale($this->locale);
Plugin::unload();
Cache::clear(false, '_cake_core_');
}
@@ -169,15 +169,15 @@ public function testPluginOverride() {
}
/**
* Tests the defaultLocale method
* Tests the locale method
*
* @return void
*/
public function testDefaultLocale() {
$this->assertEquals('en_US', I18n::defaultLocale());
$this->assertEquals('en_US', I18n::locale());
$this->assertEquals('en_US', ini_get('intl.default_locale'));
I18n::defaultLocale('fr_FR');
$this->assertEquals('fr_FR', I18n::defaultLocale());
I18n::locale('fr_FR');
$this->assertEquals('fr_FR', I18n::locale());
$this->assertEquals('fr_FR', ini_get('intl.default_locale'));
}
@@ -196,7 +196,7 @@ public function testGetTranslatorByDefaultLocale() {
return $package;
});
I18n::defaultLocale('fr_FR');
I18n::locale('fr_FR');
$translator = I18n::translator('custom');
$this->assertEquals('Le moo', $translator->translate('Cow'));
}
@@ -34,7 +34,7 @@ class NumberTest extends TestCase {
public function setUp() {
parent::setUp();
$this->Number = new Number();
$this->locale = I18n::defaultLocale();
$this->locale = I18n::locale();
}
/**
@@ -45,7 +45,7 @@ public function setUp() {
public function tearDown() {
parent::tearDown();
unset($this->Number);
I18n::defaultLocale($this->locale);
I18n::locale($this->locale);
Number::defaultCurrency(false);
}
@@ -276,7 +276,7 @@ public function testDefaultCurrency() {
$this->assertEquals('USD', $result);
$this->Number->defaultCurrency(false);
I18n::defaultLocale('es_ES');
I18n::locale('es_ES');
$this->assertEquals('EUR', $this->Number->defaultCurrency());
$this->Number->defaultCurrency('JPY');
@@ -361,7 +361,7 @@ public function testCurrencyIntlCode() {
* @return void
*/
public function testPrecisionLocalized() {
I18n::defaultLocale('fr_FR');
I18n::locale('fr_FR');
$result = $this->Number->precision(1.234);
$this->assertEquals('1,234', $result);
}
@@ -486,7 +486,7 @@ public function testToReadableSize() {
* @return void
*/
public function testReadableSizeLocalized() {
I18n::defaultLocale('fr_FR');
I18n::locale('fr_FR');
$result = $this->Number->toReadableSize(1321205);
$this->assertEquals('1,26 MB', $result);
@@ -41,7 +41,7 @@ class TranslateBehaviorTest extends TestCase {
public function tearDown() {
parent::tearDown();
I18n::defaultLocale(I18n::environmentLocale());
I18n::locale(I18n::environmentLocale());
TableRegistry::clear();
}
@@ -88,7 +88,7 @@ public function testFindSingleLocale() {
* @return void
*/
public function testFindSingleLocaleAssociatedEnv() {
I18n::defaultLocale('eng');
I18n::locale('eng');
$table = TableRegistry::get('Articles');
$table->addBehavior('Translate', ['fields' => ['title', 'body']]);
@@ -135,7 +135,7 @@ public function testFindSingleLocaleAssociatedEnv() {
];
$this->assertSame($expected, $results);
I18n::defaultLocale('spa');
I18n::locale('spa');
$results = $table->find()
->select(['id', 'title', 'body'])

0 comments on commit 78e6420

Please sign in to comment.
You can’t perform that action at this time.