Skip to content

Commit

Permalink
Fixes problem with latest versions of ICU library where AmPmMarkers i…
Browse files Browse the repository at this point in the history
…s 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.
  • Loading branch information
hostep committed Jan 18, 2024
1 parent 03621bb commit a9aab20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/internal/Magento/Framework/View/Element/Html/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,15 @@ protected function _toHtml()
$this->assignFieldsValues($localeData);

// get "am" & "pm" words
$this->assign('am', $this->encoder->encode($localeData['calendar']['gregorian']['AmPmMarkers']['0']));
$this->assign('pm', $this->encoder->encode($localeData['calendar']['gregorian']['AmPmMarkers']['1']));
// AmPmMarkers and AmPmMarkersAbbr aren't guaranteed to exist, so fallback to null if neither exist
$amWord = $localeData['calendar']['gregorian']['AmPmMarkers'][0] ??
$localeData['calendar']['gregorian']['AmPmMarkersAbbr'][0] ??
null;
$pmWord = $localeData['calendar']['gregorian']['AmPmMarkers'][1] ??
$localeData['calendar']['gregorian']['AmPmMarkersAbbr'][1] ??
null;
$this->assign('am', $this->encoder->encode($amWord));
$this->assign('pm', $this->encoder->encode($pmWord));

// get first day of week and weekend days
$this->assign(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function localesDataProvider()
['en_US'],
['ja_JP'],
['ko_KR'],
['lv_LV'],
['sv_SE'],
['de_AT'],
];
}

Expand Down

0 comments on commit a9aab20

Please sign in to comment.