Skip to content

Commit 18ffc1d

Browse files
Indrani SonawaneIndrani Sonawane
authored andcommitted
Merge remote-tracking branch '38364/fix-for-issue-38214' into community_prs_march
2 parents 76ee918 + 7645972 commit 18ffc1d

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ protected function _toHtml()
109109
);
110110

111111
$this->assignFieldsValues($localeData);
112-
113-
// 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']));
112+
$this->assignAmPmWords($localeData);
116113

117114
// get first day of week and weekend days
118115
$this->assign(
@@ -209,4 +206,23 @@ private function assignFieldsValues(\ResourceBundle $localeData): void
209206
$this->assign('week', $this->encoder->encode($localeData['fields']['week']['dn']));
210207
}
211208
}
209+
210+
/**
211+
* Assign "am" & "pm" words from the ICU data
212+
*
213+
* @param \ResourceBundle $localeData
214+
*/
215+
private function assignAmPmWords(\ResourceBundle $localeData): void
216+
{
217+
// AmPmMarkers and AmPmMarkersAbbr aren't guaranteed to exist, so fallback to null if neither exist
218+
$amWord = $localeData['calendar']['gregorian']['AmPmMarkers'][0] ??
219+
$localeData['calendar']['gregorian']['AmPmMarkersAbbr'][0] ??
220+
null;
221+
$pmWord = $localeData['calendar']['gregorian']['AmPmMarkers'][1] ??
222+
$localeData['calendar']['gregorian']['AmPmMarkersAbbr'][1] ??
223+
null;
224+
225+
$this->assign('am', $this->encoder->encode($amWord));
226+
$this->assign('pm', $this->encoder->encode($pmWord));
227+
}
212228
}

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)