Skip to content

Commit

Permalink
Merge pull request #35 from Laravel-Lang/2.x
Browse files Browse the repository at this point in the history
The `withCountries` and `withCurrencies` options are now disabled by default
  • Loading branch information
andrey-helldar authored Apr 6, 2024
2 parents fdb9ea3 + 57311fa commit 35aa06e
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 48 deletions.
18 changes: 9 additions & 9 deletions src/Facades/Locales.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
* @method static bool isAvailable(string|Locale|null $locale)
* @method static bool isInstalled(string|Locale|null $locale)
* @method static bool isProtected(string|Locale|null $locale)
* @method static Collection<LocaleData> available(bool $withCountries = true, bool $withCurrencies = true)
* @method static Collection<LocaleData> installed(bool $withProtects = true, bool $withCountries = true, bool $withCurrencies = true)
* @method static Collection<LocaleData> notInstalled(bool $withCountries = true, bool $withCurrencies = true)
* @method static Collection<LocaleData> protects(bool $withCountries = true, bool $withCurrencies = true)
* @method static LocaleData get(mixed $locale, bool $withCountry = true, bool $withCurrency = true)
* @method static LocaleData getCurrent(bool $withCountry = true, bool $withCurrency = true)
* @method static LocaleData getDefault(bool $withCountry = true, bool $withCurrency = true)
* @method static LocaleData getFallback(bool $withCountry = true, bool $withCurrency = true)
* @method static LocaleData info(mixed $locale, bool $withCountry = true, bool $withCurrency = true)
* @method static Collection<LocaleData> available(bool $withCountries = false, bool $withCurrencies = false)
* @method static Collection<LocaleData> installed(bool $withProtects = true, bool $withCountries = false, bool $withCurrencies = false)
* @method static Collection<LocaleData> notInstalled(bool $withCountries = false, bool $withCurrencies = false)
* @method static Collection<LocaleData> protects(bool $withCountries = false, bool $withCurrencies = false)
* @method static LocaleData get(mixed $locale, bool $withCountry = false, bool $withCurrency = false)
* @method static LocaleData getCurrent(bool $withCountry = false, bool $withCurrency = false)
* @method static LocaleData getDefault(bool $withCountry = false, bool $withCurrency = false)
* @method static LocaleData getFallback(bool $withCountry = false, bool $withCurrency = false)
* @method static LocaleData info(mixed $locale, bool $withCountry = false, bool $withCurrency = false)
* @method static RawLocales raw()
* @method static void set(mixed $locale)
*/
Expand Down
20 changes: 10 additions & 10 deletions src/Services/Locales.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function raw(): RawLocales
return $this->raw;
}

public function available(bool $withCountries = true, bool $withCurrencies = true): Collection
public function available(bool $withCountries = false, bool $withCurrencies = false): Collection
{
return $this->registry(
__METHOD__,
Expand All @@ -53,24 +53,24 @@ public function available(bool $withCountries = true, bool $withCurrencies = tru

public function installed(
bool $withProtects = true,
bool $withCountries = true,
bool $withCurrencies = true
bool $withCountries = false,
bool $withCurrencies = false
): Collection {
return $this->registry(
[__METHOD__, $withProtects],
fn () => $this->mapLocales($this->raw->installed($withProtects), $withCountries, $withCurrencies)
);
}

public function notInstalled(bool $withCountries = true, bool $withCurrencies = true): Collection
public function notInstalled(bool $withCountries = false, bool $withCurrencies = false): Collection
{
return $this->registry(
__METHOD__,
fn () => $this->mapLocales($this->raw->notInstalled(), $withCountries, $withCurrencies)
);
}

public function protects(bool $withCountries = true, bool $withCurrencies = true): Collection
public function protects(bool $withCountries = false, bool $withCurrencies = false): Collection
{
return $this->registry(
__METHOD__,
Expand All @@ -93,36 +93,36 @@ public function isProtected(Locale|string|null $locale): bool
return $this->raw->isProtected($locale);
}

public function get(mixed $locale, bool $withCountry = true, bool $withCurrency = true): LocaleData
public function get(mixed $locale, bool $withCountry = false, bool $withCurrency = false): LocaleData
{
return $this->registry(
[__METHOD__, $locale, $this->appLocale()],
fn () => $this->map($this->raw->get($locale), $withCountry, $withCurrency)
);
}

public function info(mixed $locale, bool $withCountry = true, bool $withCurrency = true): LocaleData
public function info(mixed $locale, bool $withCountry = false, bool $withCurrency = false): LocaleData
{
return $this->registry(
[__METHOD__, $locale, $this->appLocale()],
fn () => $this->map($this->raw->info($locale), $withCountry, $withCurrency)
);
}

public function getCurrent(bool $withCountry = true, bool $withCurrency = true): LocaleData
public function getCurrent(bool $withCountry = false, bool $withCurrency = false): LocaleData
{
return $this->getDefault($withCountry, $withCurrency);
}

public function getDefault(bool $withCountry = true, bool $withCurrency = true): LocaleData
public function getDefault(bool $withCountry = false, bool $withCurrency = false): LocaleData
{
return $this->registry(
[__METHOD__, $this->appLocale()],
fn () => $this->map($this->raw->getDefault(), $withCountry, $withCurrency)
);
}

public function getFallback(bool $withCountry = true, bool $withCurrency = true): LocaleData
public function getFallback(bool $withCountry = false, bool $withCurrency = false): LocaleData
{
return $this->registry(
[__METHOD__, $this->appLocale()],
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Data/LocalizedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
$nativeCurrency = CurrencyNames::get()->all();
$localizedCurrency = CurrencyNames::get($locale)->all();

foreach (Locales::available() as $item) {
foreach (Locales::available(true, true) as $item) {
// Locales
expect($item->native)->toBe($nativeLocale[$item->code]);
expect($item->localized)->toBe($localizedLocale[$item->code]);
Expand Down Expand Up @@ -87,7 +87,7 @@
$nativeCountry = CountryNames::get()->all();
$localizedCountry = CountryNames::get($locale)->all();

foreach (Locales::available(withCurrencies: false) as $item) {
foreach (Locales::available(true) as $item) {
// Locales
expect($item->native)->toBe($nativeLocale[$item->code]);
expect($item->localized)->toBe($localizedLocale[$item->code]);
Expand Down Expand Up @@ -122,7 +122,7 @@
$nativeCurrency = CurrencyNames::get()->all();
$localizedCurrency = CurrencyNames::get($locale)->all();

foreach (Locales::available(withCountries: false) as $item) {
foreach (Locales::available(withCurrencies: true) as $item) {
// Locales
expect($item->native)->toBe($nativeLocale[$item->code]);
expect($item->localized)->toBe($localizedLocale[$item->code]);
Expand Down Expand Up @@ -151,7 +151,7 @@
$nativeLocale = LocaleNames::get();
$localizedLocale = LocaleNames::get($locale);

foreach (Locales::available(false, false) as $item) {
foreach (Locales::available() as $item) {
expect($item->native)->toBe($nativeLocale[$item->code]);
expect($item->localized)->toBe($localizedLocale[$item->code]);

Expand Down Expand Up @@ -180,7 +180,7 @@ function (
expect(app()->getLocale())->toBe($forLocale);
expect(Locales::getDefault()->code)->toBe($forLocale);

expect(Locales::info($locale))
expect(Locales::info($locale, true, true))
// Locale
->code->toBe($locale)
->native->toBe($native)
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Facades/Locales/AvailableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@
})->with('incorrect-locales');

it('checks for missing currency information')
->expect(fn () => Locales::available(withCurrencies: false))
->expect(fn () => Locales::available(true))
->each(fn (Expectation|LocaleData $item) => $item
->country->not->toBeNull()
->currency->toBeNull()
);

it('checks for missing country information')
->expect(fn () => Locales::available(withCountries: false))
->expect(fn () => Locales::available(withCurrencies: true))
->each(fn (Expectation|LocaleData $item) => $item
->country->toBeNull()
->currency->not->toBeNull()
);

it('checks for missing country and currency information')
->expect(fn () => Locales::available(false, false))
->expect(fn () => Locales::available())
->each(fn (Expectation|LocaleData $item) => $item
->country->toBeNull()
->currency->toBeNull()
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Facades/Locales/GetCurrentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@
});

it('checks for missing currency information')
->expect(fn () => Locales::getCurrent(withCurrency: false))
->expect(fn () => Locales::getCurrent(true))
->country->not->toBeNull()
->currency->toBeNull();

it('checks for missing country information')
->expect(fn () => Locales::getCurrent(withCountry: false))
->expect(fn () => Locales::getCurrent(withCurrency: true))
->country->toBeNull()
->currency->not->toBeNull();

it('checks for missing country and currency information')
->expect(fn () => Locales::getCurrent(false, false))
->expect(fn () => Locales::getCurrent())
->country->toBeNull()
->currency->toBeNull();

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Facades/Locales/GetDefaultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@
});

it('checks for missing currency information')
->expect(fn () => Locales::getDefault(withCurrency: false))
->expect(fn () => Locales::getDefault(true))
->country->not->toBeNull()
->currency->toBeNull();

it('checks for missing country information')
->expect(fn () => Locales::getDefault(withCountry: false))
->expect(fn () => Locales::getDefault(withCurrency: true))
->country->toBeNull()
->currency->not->toBeNull();

it('checks for missing country and currency information')
->expect(fn () => Locales::getDefault(false, false))
->expect(fn () => Locales::getDefault())
->country->toBeNull()
->currency->toBeNull();

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Facades/Locales/GetFallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@
})->with('aliased-locales');

it('checks for missing currency information')
->expect(fn () => Locales::getFallback(withCurrency: false))
->expect(fn () => Locales::getFallback(true))
->country->not->toBeNull()
->currency->toBeNull();

it('checks for missing country information')
->expect(fn () => Locales::getFallback(withCountry: false))
->expect(fn () => Locales::getFallback(withCurrency: true))
->country->toBeNull()
->currency->not->toBeNull();

it('checks for missing country and currency information')
->expect(fn () => Locales::getFallback(false, false))
->expect(fn () => Locales::getFallback())
->country->toBeNull()
->currency->toBeNull();

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Facades/Locales/GetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,17 @@ function () {
})->with('locales');

it('checks for missing currency information')
->expect(fn () => Locales::get(Locale::Vietnamese, withCurrency: false))
->expect(fn () => Locales::get(Locale::Vietnamese, true))
->country->not->toBeNull()
->currency->toBeNull();

it('checks for missing country information')
->expect(fn () => Locales::get(Locale::Vietnamese, withCountry: false))
->expect(fn () => Locales::get(Locale::Vietnamese, withCurrency: true))
->country->toBeNull()
->currency->not->toBeNull();

it('checks for missing country and currency information')
->expect(fn () => Locales::get(Locale::Vietnamese, false, false))
->expect(fn () => Locales::get(Locale::Vietnamese))
->country->toBeNull()
->currency->toBeNull();

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Facades/Locales/InstalledTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@

setLocales(Locale::German, Locale::French);

expect(Locales::installed(withCurrencies: false))
expect(Locales::installed(withCountries: true))
->each(fn (Expectation|LocaleData $item) => $item
->country->not->toBeNull()
->currency->toBeNull()
Expand All @@ -136,7 +136,7 @@

setLocales(Locale::German, Locale::French);

expect(Locales::installed(withCountries: false))
expect(Locales::installed(withCurrencies: true))
->each(fn (Expectation|LocaleData $item) => $item
->country->toBeNull()
->currency->not->toBeNull()
Expand All @@ -148,7 +148,7 @@

setLocales(Locale::German, Locale::French);

expect(Locales::installed(withCountries: false, withCurrencies: false))
expect(Locales::installed())
->each(fn (Expectation|LocaleData $item) => $item
->country->toBeNull()
->currency->toBeNull()
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Facades/Locales/NotInstalledTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

setLocales(Locale::German, Locale::French);

expect(Locales::notInstalled(withCurrencies: false))
expect(Locales::notInstalled(true))
->each(fn (Expectation|LocaleData $item) => $item
->country->not->toBeNull()
->currency->toBeNull()
Expand All @@ -100,7 +100,7 @@

setLocales(Locale::German, Locale::French);

expect(Locales::notInstalled(withCountries: false))
expect(Locales::notInstalled(withCurrencies: true))
->each(fn (Expectation|LocaleData $item) => $item
->country->toBeNull()
->currency->not->toBeNull()
Expand All @@ -112,7 +112,7 @@

setLocales(Locale::German, Locale::French);

expect(Locales::notInstalled(withCountries: false, withCurrencies: false))
expect(Locales::notInstalled())
->each(fn (Expectation|LocaleData $item) => $item
->country->toBeNull()
->currency->toBeNull()
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Facades/Locales/ProtectsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

setLocales(Locale::German, Locale::French);

expect(Locales::protects(withCurrencies: false))
expect(Locales::protects(true))
->each(fn (Expectation|LocaleData $item) => $item
->country->not->toBeNull()
->currency->toBeNull()
Expand All @@ -106,7 +106,7 @@

setLocales(Locale::German, Locale::French);

expect(Locales::protects(withCountries: false))
expect(Locales::protects(withCurrencies: true))
->each(fn (Expectation|LocaleData $item) => $item
->country->toBeNull()
->currency->not->toBeNull()
Expand All @@ -118,7 +118,7 @@

setLocales(Locale::German, Locale::French);

expect(Locales::protects(withCountries: false, withCurrencies: false))
expect(Locales::protects())
->each(fn (Expectation|LocaleData $item) => $item
->country->toBeNull()
->currency->toBeNull()
Expand Down

0 comments on commit 35aa06e

Please sign in to comment.