$multilingual = CRM_Core_I18n::isMultilingual();
while ($dao->fetch()) {
- // switch language if necessary
- if ($multilingual) {
- $preferred_language = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contactID, 'preferred_language');
- CRM_Core_I18n::singleton()->setLocale(CRM_Core_BAO_ActionSchedule::pickLocale($actionSchedule->communication_language, $preferred_language));
- }
-
$errors = [];
try {
$tokenProcessor = self::createTokenProcessor($actionSchedule, $mapping);
- $tokenProcessor->addRow()
+ $row = $tokenProcessor->addRow()
->context('contactId', $dao->contactID)
->context('actionSearchResult', (object) $dao->toArray());
+
+ // switch language if necessary
+ if ($multilingual) {
+ $preferred_language = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contactID, 'preferred_language');
+ $row->context('locale', CRM_Core_BAO_ActionSchedule::pickLocale($actionSchedule->communication_language, $preferred_language));
+ }
+
foreach ($tokenProcessor->evaluate()->getRows() as $tokenRow) {
if ($actionSchedule->mode === 'SMS' || $actionSchedule->mode === 'User_Preference') {
CRM_Utils_Array::extend($errors, self::sendReminderSms($tokenRow, $actionSchedule, $dao->contactID));