Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions lib/internal/Magento/Framework/View/Element/Html/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ 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']));
$this->assignAmPmWords($localeData);

// get first day of week and weekend days
$this->assign(
Expand Down Expand Up @@ -209,4 +206,23 @@ private function assignFieldsValues(\ResourceBundle $localeData): void
$this->assign('week', $this->encoder->encode($localeData['fields']['week']['dn']));
}
}

/**
* Assign "am" & "pm" words from the ICU data
*
* @param \ResourceBundle $localeData
*/
private function assignAmPmWords(\ResourceBundle $localeData): void
{
// 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));
}
}
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