(REF) ActionSchedule - Convert setCommunicationLanguage(...) to setLocale(pickLocale...
authorTim Otten <totten@civicrm.org>
Tue, 10 Aug 2021 03:49:30 +0000 (20:49 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 10 Aug 2021 23:37:02 +0000 (16:37 -0700)
CRM/Core/BAO/ActionSchedule.php

index e804f3bc76573eae34d21b9ce1368627c62484b9..abcd747f4448aa416444c9067a36a8e8df98c8cf 100644 (file)
@@ -271,7 +271,7 @@ FROM civicrm_action_schedule cas
         // switch language if necessary
         if ($multilingual) {
           $preferred_language = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contactID, 'preferred_language');
-          CRM_Core_BAO_ActionSchedule::setCommunicationLanguage($actionSchedule->communication_language, $preferred_language);
+          CRM_Core_I18n::singleton()->setLocale(CRM_Core_BAO_ActionSchedule::pickLocale($actionSchedule->communication_language, $preferred_language));
         }
 
         $errors = [];
@@ -401,10 +401,11 @@ FROM civicrm_action_schedule cas
   }
 
   /**
-   * @param $communication_language
-   * @param $preferred_language
+   * @param string|null $communication_language
+   * @param string|null $preferred_language
+   * @return string
    */
-  public static function setCommunicationLanguage($communication_language, $preferred_language) {
+  public static function pickLocale($communication_language, $preferred_language) {
     $currentLocale = CRM_Core_I18n::getLocale();
     $language = $currentLocale;
 
@@ -425,8 +426,7 @@ FROM civicrm_action_schedule cas
     }
 
     // change the language
-    $i18n = CRM_Core_I18n::singleton();
-    $i18n->setLocale($language);
+    return $language;
   }
 
   /**