From ba0f343dcfa9d7be8b83be51220dad4c23388f1d Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sun, 31 Oct 2021 17:55:54 +0000 Subject: [PATCH] Avoid hardcoded text in error strings; make translatable --- CRM/Admin/Form/Setting/Mapping.php | 2 +- CRM/Admin/Form/Setting/Smtp.php | 12 ++++++------ CRM/Contact/Form/Edit/Household.php | 2 +- CRM/Contact/Form/Edit/Organization.php | 2 +- CRM/Core/BAO/CustomField.php | 6 +++--- CRM/Core/Form/Task/PDFLetterCommon.php | 8 ++++---- CRM/Report/Form.php | 4 ++-- CRM/Utils/System/WordPress.php | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CRM/Admin/Form/Setting/Mapping.php b/CRM/Admin/Form/Setting/Mapping.php index 07071e0d6c..b07d9f8788 100644 --- a/CRM/Admin/Form/Setting/Mapping.php +++ b/CRM/Admin/Form/Setting/Mapping.php @@ -52,7 +52,7 @@ class CRM_Admin_Form_Setting_Mapping extends CRM_Admin_Form_Setting { } if ($fields['mapProvider'] == 'OpenStreetMaps' && $fields['geoProvider'] == '') { - $errors['geoProvider'] = "Please select a Geocoding Provider - Open Street Maps does not provide geocoding."; + $errors['geoProvider'] = ts('Please select a Geocoding Provider - Open Street Maps does not provide geocoding.'); } return $errors; diff --git a/CRM/Admin/Form/Setting/Smtp.php b/CRM/Admin/Form/Setting/Smtp.php index cf44ea62d6..ada9c30feb 100644 --- a/CRM/Admin/Form/Setting/Smtp.php +++ b/CRM/Admin/Form/Setting/Smtp.php @@ -218,26 +218,26 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { public static function formRule($fields) { if ($fields['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) { if (empty($fields['smtpServer'])) { - $errors['smtpServer'] = 'SMTP Server name is a required field.'; + $errors['smtpServer'] = ts('SMTP Server name is a required field.'); } if (empty($fields['smtpPort'])) { - $errors['smtpPort'] = 'SMTP Port is a required field.'; + $errors['smtpPort'] = ts('SMTP Port is a required field.'); } if (!empty($fields['smtpAuth'])) { if (empty($fields['smtpUsername'])) { - $errors['smtpUsername'] = 'If your SMTP server requires authentication please provide a valid user name.'; + $errors['smtpUsername'] = ts('If your SMTP server requires authentication please provide a valid user name.'); } if (empty($fields['smtpPassword'])) { - $errors['smtpPassword'] = 'If your SMTP server requires authentication, please provide a password.'; + $errors['smtpPassword'] = ts('If your SMTP server requires authentication, please provide a password.'); } } } if ($fields['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL) { if (!$fields['sendmail_path']) { - $errors['sendmail_path'] = 'Sendmail Path is a required field.'; + $errors['sendmail_path'] = ts('Sendmail Path is a required field.'); } if (!$fields['sendmail_args']) { - $errors['sendmail_args'] = 'Sendmail Argument is a required field.'; + $errors['sendmail_args'] = ts('Sendmail Argument is a required field.'); } } diff --git a/CRM/Contact/Form/Edit/Household.php b/CRM/Contact/Form/Edit/Household.php index 40d9113578..2428454dfa 100644 --- a/CRM/Contact/Form/Edit/Household.php +++ b/CRM/Contact/Form/Edit/Household.php @@ -73,7 +73,7 @@ class CRM_Contact_Form_Edit_Household { // make sure that household name is set if (empty($fields['household_name'])) { - $errors['household_name'] = 'Household Name should be set.'; + $errors['household_name'] = ts('Household Name should be set.'); } return empty($errors) ? TRUE : $errors; diff --git a/CRM/Contact/Form/Edit/Organization.php b/CRM/Contact/Form/Edit/Organization.php index bac2996ade..91776591be 100644 --- a/CRM/Contact/Form/Edit/Organization.php +++ b/CRM/Contact/Form/Edit/Organization.php @@ -74,7 +74,7 @@ class CRM_Contact_Form_Edit_Organization { // make sure that organization name is set if (empty($fields['organization_name'])) { - $errors['organization_name'] = 'Organization Name should be set.'; + $errors['organization_name'] = ts('Organization Name should be set.'); } // add code to make sure that the uniqueness criteria is satisfied diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index c5421a604b..b7a92bae4c 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1796,21 +1796,21 @@ SELECT $columnName $field = new CRM_Core_DAO_CustomField(); $field->id = $fieldID; if (!$field->find(TRUE)) { - $errors['fieldID'] = 'Invalid ID for custom field'; + $errors['fieldID'] = ts('Invalid ID for custom field'); return $errors; } $oldGroup = new CRM_Core_DAO_CustomGroup(); $oldGroup->id = $field->custom_group_id; if (!$oldGroup->find(TRUE)) { - $errors['fieldID'] = 'Invalid ID for old custom group'; + $errors['fieldID'] = ts('Invalid ID for old custom group'); return $errors; } $newGroup = new CRM_Core_DAO_CustomGroup(); $newGroup->id = $newGroupID; if (!$newGroup->find(TRUE)) { - $errors['newGroupID'] = 'Invalid ID for new custom group'; + $errors['newGroupID'] = ts('Invalid ID for new custom group'); return $errors; } diff --git a/CRM/Core/Form/Task/PDFLetterCommon.php b/CRM/Core/Form/Task/PDFLetterCommon.php index f3774ce75b..acd483a4a6 100644 --- a/CRM/Core/Form/Task/PDFLetterCommon.php +++ b/CRM/Core/Form/Task/PDFLetterCommon.php @@ -236,16 +236,16 @@ class CRM_Core_Form_Task_PDFLetterCommon { $errors['saveTemplateName'] = ts("Enter name to save message template"); } if (!is_numeric($fields['margin_left'])) { - $errors['margin_left'] = 'Margin must be numeric'; + $errors['margin_left'] = ts('Margin must be numeric'); } if (!is_numeric($fields['margin_right'])) { - $errors['margin_right'] = 'Margin must be numeric'; + $errors['margin_right'] = ts('Margin must be numeric'); } if (!is_numeric($fields['margin_top'])) { - $errors['margin_top'] = 'Margin must be numeric'; + $errors['margin_top'] = ts('Margin must be numeric'); } if (!is_numeric($fields['margin_bottom'])) { - $errors['margin_bottom'] = 'Margin must be numeric'; + $errors['margin_bottom'] = ts('Margin must be numeric'); } return empty($errors) ? TRUE : $errors; } diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index da4e6ba09d..884c5a8c83 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -1798,14 +1798,14 @@ class CRM_Report_Form extends CRM_Core_Form { if (array_key_exists($fieldName, $fields['group_bys']) && !array_key_exists($fieldName, $fields['fields']) ) { - $errors['fields'] = "Please make sure fields selected in 'Group by Columns' section are also selected in 'Display Columns' section."; + $errors['fields'] = ts("Please make sure fields selected in 'Group by Columns' section are also selected in 'Display Columns' section."); } elseif (array_key_exists($fieldName, $fields['group_bys'])) { foreach ($fields['fields'] as $fld => $val) { if (!array_key_exists($fld, $fields['group_bys']) && !in_array($fld, $ignoreFields) ) { - $errors['fields'] = "Please ensure that fields selected in 'Display Columns' are also selected in 'Group by Columns' section."; + $errors['fields'] = ts("Please ensure that fields selected in 'Display Columns' are also selected in 'Group by Columns' section."); } } } diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 5348ae6cf1..ecb3abd394 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -984,7 +984,7 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { if (!empty($params['mail'])) { if (!is_email($params['mail'])) { - $errors[$emailName] = "Your email is invaid"; + $errors[$emailName] = ts("Your email is invalid"); } elseif (email_exists($params['mail'])) { $errors[$emailName] = ts('The email address %1 already has an account associated with it. Have you forgotten your password?', -- 2.25.1