Skip to content

Commit 2278677

Browse files
authored
bug #194 [Bug] Locale support improved (SirDomin)
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
2 parents 5203078 + 51623cd commit 2278677

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

spec/Processor/LocaleProcessorSpec.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ function it_returns_same_locale_if_it_is_valid(): void
2121
$this->process('ja_JP_TRADITIONAL')->shouldReturn('ja_JP_TRADITIONAL');
2222
$this->process('sd_Arab_PK')->shouldReturn('sd_Arab_PK');
2323
}
24+
25+
function it_returns_correct_locale_for_en_locale(): void
26+
{
27+
$this->process('en')->shouldReturn('en_US');
28+
}
2429
}

src/Processor/LocaleProcessor.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ public function process(string $locale): string
1414
return $locale;
1515
}
1616

17+
if ($locale === 'en') {
18+
return 'en_US';
19+
}
20+
1721
$locales = array_filter(Locales::getLocales(), function (string $targetLocale) use ($locale): bool {
1822
return
1923
strpos($targetLocale, $locale) === 0 &&
20-
strpos($targetLocale, '_') !== false
24+
strpos($targetLocale, '_') !== false &&
25+
strlen($targetLocale) === 5
2126
;
2227
});
2328

0 commit comments

Comments
 (0)