*
*/
public static function getAbbrWeekdayNames() {
- static $days = [];
+ $key = 'abbrDays_' . \CRM_Core_I18n::getLocale();
+ $days = &\Civi::$statics[__CLASS__][$key];
if (!$days) {
+ $days = [];
// First day of the week
$firstDay = Civi::settings()->get('weekBegins');
*
*/
public static function getFullWeekdayNames() {
- static $days = [];
+ $key = 'fullDays_' . \CRM_Core_I18n::getLocale();
+ $days = &\Civi::$statics[__CLASS__][$key];
if (!$days) {
+ $days = [];
// First day of the week
$firstDay = Civi::settings()->get('weekBegins');
*
*/
public static function &getAbbrMonthNames($month = FALSE) {
- static $abbrMonthNames;
+ $key = 'abbrMonthNames_' . \CRM_Core_I18n::getLocale();
+ $abbrMonthNames = &\Civi::$statics[__CLASS__][$key];
if (!isset($abbrMonthNames)) {
// set LC_TIME and build the arrays from locale-provided names
*
*/
public static function &getFullMonthNames() {
- if (empty(\Civi::$statics[__CLASS__]['fullMonthNames'])) {
+ $key = 'fullMonthNames_' . \CRM_Core_I18n::getLocale();
+ if (empty(\Civi::$statics[__CLASS__][$key])) {
// Not relying on strftime because it depends on the operating system
// and most people will not have a non-US locale configured out of the box
// Ignoring other date names for now, since less visible by default
- \Civi::$statics[__CLASS__]['fullMonthNames'] = [
+ \Civi::$statics[__CLASS__][$key] = [
1 => ts('January'),
2 => ts('February'),
3 => ts('March'),
];
}
- return \Civi::$statics[__CLASS__]['fullMonthNames'];
+ return \Civi::$statics[__CLASS__][$key];
}
/**
], $date);
}
+ public function testLocalizeConsts() {
+ $expect['en_US'] = ['Jan', 'Tue', 'March', 'Thursday'];
+ $expect['fr_FR'] = ['janv.', 'mar.', 'Mars', 'jeudi'];
+ $expect['es_MX'] = ['ene', 'mar', 'Marzo', 'jueves'];
+
+ foreach ($expect as $lang => $expectNames) {
+ $useLocale = CRM_Utils_AutoClean::swapLocale($lang);
+ $actualNames = [
+ CRM_Utils_Date::getAbbrMonthNames()[1],
+ CRM_Utils_Date::getAbbrWeekdayNames()[2],
+ CRM_Utils_Date::getFullMonthNames()[3],
+ CRM_Utils_Date::getFullWeekdayNames()[4],
+ ];
+ $this->assertEquals($expectNames, $actualNames, "Check temporal names in $lang");
+ unset($useLocale);
+ }
+ }
+
}