Skip to content

Commit 52e80be

Browse files
authored
Fixed currency dropdowns broken for regional locales (#609) (#612)
1 parent 6fa89fe commit 52e80be

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

app/code/core/Mage/Core/Model/Locale.php

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -382,33 +382,27 @@ protected function _getCurrencyList(): array
382382
$locale = $this->getLocaleCode();
383383
$currencies = [];
384384

385-
// Get all available currencies from ICU data using ResourceBundle
386-
$bundle = ResourceBundle::create($locale, 'ICUDATA-curr');
387-
if ($bundle !== null) {
385+
// For regional locales (e.g. en_GB), the ICU bundle only contains
386+
// locale-specific currency name overrides, not the full list.
387+
// Load from the root language bundle first, then merge overrides.
388+
$primaryLanguage = \Locale::getPrimaryLanguage($locale);
389+
$bundlesToLoad = ($primaryLanguage !== $locale)
390+
? [$primaryLanguage, $locale]
391+
: [$locale];
392+
393+
foreach ($bundlesToLoad as $bundleLocale) {
394+
$bundle = ResourceBundle::create($bundleLocale, 'ICUDATA-curr');
395+
if ($bundle === null) {
396+
continue;
397+
}
388398
$currencyData = $bundle->get('Currencies');
389-
390-
if ($currencyData !== null) {
391-
// Get list of all currency codes
392-
$allCodes = [];
393-
foreach ($currencyData as $code => $data) {
394-
if (strlen($code) === 3 && ctype_alpha($code)) {
395-
$allCodes[] = $code;
396-
}
397-
}
398-
399-
// Now get the data for each code
400-
foreach ($allCodes as $code) {
401-
$currInfo = $currencyData->get($code);
402-
if ($currInfo !== null) {
403-
// Get the display name (at index 1)
404-
$displayName = $currInfo->get(1);
405-
if ($displayName !== null) {
406-
$currencies[$code] = $displayName;
407-
} else {
408-
// Fallback to code
409-
$currencies[$code] = $code;
410-
}
411-
}
399+
if ($currencyData === null) {
400+
continue;
401+
}
402+
foreach ($currencyData as $code => $data) {
403+
if (strlen($code) === 3 && ctype_alpha($code)) {
404+
$displayName = $data->get(1);
405+
$currencies[$code] = $displayName ?? $code;
412406
}
413407
}
414408
}

0 commit comments

Comments
 (0)