Skip to content

Commit

Permalink
#7352 Locale::getFormattedDisplayNames update to deduce locale code w…
Browse files Browse the repository at this point in the history
…ith @ char
  • Loading branch information
touhidurabir authored and asmecher committed Mar 9, 2023
1 parent 0446b86 commit 429db4a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classes/i18n/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,13 @@ public function getFormattedDisplayNames(array $filterByLocales = null, array $l

$localeCodesCount = array_count_values(
collect(array_keys($filterByLocales ?? $locales))
->map(fn(string $value) => explode('_', $value)[0])
->map(fn(string $value) => trim(explode('@', explode('_', $value)[0])[0]))
->toArray()
);

return collect($locales)
->map(function(LocaleMetadata $locale, string $localeKey) use ($localeCodesCount, $langLocaleStatus, $omitLocaleCodeInDisplay) {
$localeCode = explode('_', $localeKey)[0];
$localeCode = trim(explode('@', explode('_', $localeKey)[0])[0]);
$localeDisplay = $locale->getDisplayName(null, ($localeCodesCount[$localeCode] ?? 0) > 1, $langLocaleStatus);
return $localeDisplay . ($omitLocaleCodeInDisplay ? "" : " ({$localeKey})");
})
Expand Down

0 comments on commit 429db4a

Please sign in to comment.