From 9800572e998d38c091a482d1143fb380c81a6480 Mon Sep 17 00:00:00 2001
From: Mathieu Lutfy <mathieu@symbiotic.coop>
Date: Mon, 16 Aug 2021 11:41:45 -0400
Subject: [PATCH] dev/translation#71 getFullMonthNames: do not rely on the
 operating system locale for translation

---
 CRM/Report/Form.php | 16 ++--------------
 CRM/Utils/Date.php  | 29 ++++++++++++++++++++---------
 2 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php
index 1e297cbb83c..352bbf35ecc 100644
--- a/CRM/Report/Form.php
+++ b/CRM/Report/Form.php
@@ -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'];
diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php
index 093862b8449..632eb4910bb 100644
--- a/CRM/Utils/Date.php
+++ b/CRM/Utils/Date.php
@@ -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'];
   }
 
   /**
-- 
GitLab