Skip to content

Commit a9aab20

Browse files
committed
Fixes problem with latest versions of ICU library where AmPmMarkers is no longer defined for each locale. If that's the case fall back to AmPmMarkersAbbr and if that one doesn't exist, fallback to null. This fixes a second problem where previously we always returned 'null' due to the index being a string instead of an integer. That's also fixed now.
1 parent 03621bb commit a9aab20

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/internal/Magento/Framework/View/Element/Html/Calendar.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,15 @@ protected function _toHtml()
111111
$this->assignFieldsValues($localeData);
112112

113113
// get "am" & "pm" words
114-
$this->assign('am', $this->encoder->encode($localeData['calendar']['gregorian']['AmPmMarkers']['0']));
115-
$this->assign('pm', $this->encoder->encode($localeData['calendar']['gregorian']['AmPmMarkers']['1']));
114+
// AmPmMarkers and AmPmMarkersAbbr aren't guaranteed to exist, so fallback to null if neither exist
115+
$amWord = $localeData['calendar']['gregorian']['AmPmMarkers'][0] ??
116+
$localeData['calendar']['gregorian']['AmPmMarkersAbbr'][0] ??
117+
null;
118+
$pmWord = $localeData['calendar']['gregorian']['AmPmMarkers'][1] ??
119+
$localeData['calendar']['gregorian']['AmPmMarkersAbbr'][1] ??
120+
null;
121+
$this->assign('am', $this->encoder->encode($amWord));
122+
$this->assign('pm', $this->encoder->encode($pmWord));
116123

117124
// get first day of week and weekend days
118125
$this->assign(

lib/internal/Magento/Framework/View/Test/Unit/Element/Html/CalendarTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public function localesDataProvider()
4848
['en_US'],
4949
['ja_JP'],
5050
['ko_KR'],
51+
['lv_LV'],
52+
['sv_SE'],
53+
['de_AT'],
5154
];
5255
}
5356

0 commit comments

Comments
 (0)