Skip to content

Commit

Permalink
bug #194 [Bug] Locale support improved (SirDomin)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.0-dev branch.

Discussion
----------

fixes #188 

paypal supports only 2 en_XX locales, it changes all en locales to en_US

Commits
-------

82bdc3a add spec to en locale
d6c2cd0 locale processor supports en locale
51623cd pr-fix
  • Loading branch information
Zales0123 authored Apr 22, 2021
2 parents 5203078 + 51623cd commit 2278677
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions spec/Processor/LocaleProcessorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ function it_returns_same_locale_if_it_is_valid(): void
$this->process('ja_JP_TRADITIONAL')->shouldReturn('ja_JP_TRADITIONAL');
$this->process('sd_Arab_PK')->shouldReturn('sd_Arab_PK');
}

function it_returns_correct_locale_for_en_locale(): void
{
$this->process('en')->shouldReturn('en_US');
}
}
7 changes: 6 additions & 1 deletion src/Processor/LocaleProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ public function process(string $locale): string
return $locale;
}

if ($locale === 'en') {
return 'en_US';
}

$locales = array_filter(Locales::getLocales(), function (string $targetLocale) use ($locale): bool {
return
strpos($targetLocale, $locale) === 0 &&
strpos($targetLocale, '_') !== false
strpos($targetLocale, '_') !== false &&
strlen($targetLocale) === 5
;
});

Expand Down

0 comments on commit 2278677

Please sign in to comment.