Skip to content
Snippets Groups Projects
Commit 9800572e authored by bgm's avatar bgm Committed by bgm
Browse files

translation#71 getFullMonthNames: do not rely on the operating system locale for translation

parent d32b0c38
No related branches found
No related tags found
No related merge requests found
......@@ -1361,20 +1361,8 @@ class CRM_Report_Form extends CRM_Core_Form {
!is_array($field['options']) || empty($field['options'])
) {
// If there's no option list for this filter, define one.
$field['options'] = [
1 => ts('January'),
2 => ts('February'),
3 => ts('March'),
4 => ts('April'),
5 => ts('May'),
6 => ts('June'),
7 => ts('July'),
8 => ts('August'),
9 => ts('September'),
10 => ts('October'),
11 => ts('November'),
12 => ts('December'),
];
$field['options'] = CRM_Utils_Date::getFullMonthNames();
// Add this option list to this column _columns. This is
// required so that filter statistics show properly.
$this->_columns[$table]['filters'][$fieldName]['options'] = $field['options'];
......
......@@ -237,16 +237,27 @@ class CRM_Utils_Date {
*
*/
public static function &getFullMonthNames() {
static $fullMonthNames;
if (!isset($fullMonthNames)) {
// set LC_TIME and build the arrays from locale-provided names
CRM_Core_I18n::setLcTime();
for ($i = 1; $i <= 12; $i++) {
$fullMonthNames[$i] = strftime('%B', mktime(0, 0, 0, $i, 10, 1970));
}
if (empty(\Civi::$statics[__CLASS__]['fullMonthNames'])) {
// 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'] = [
1 => ts('January'),
2 => ts('February'),
3 => ts('March'),
4 => ts('April'),
5 => ts('May'),
6 => ts('June'),
7 => ts('July'),
8 => ts('August'),
9 => ts('September'),
10 => ts('October'),
11 => ts('November'),
12 => ts('December'),
];
}
return $fullMonthNames;
return \Civi::$statics[__CLASS__]['fullMonthNames'];
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment