From 99483ce807074cfd70987eb1d52fb5fddd94511c Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 14 Mar 2015 22:12:31 -0400 Subject: [PATCH] Fix plural strings --- CRM/Activity/Form/Task/AddToTag.php | 4 ++-- CRM/Activity/Form/Task/Delete.php | 17 +++++++++++---- CRM/Activity/Form/Task/RemoveFromTag.php | 2 +- CRM/Campaign/Form/Task/Release.php | 18 ++++++++++++---- CRM/Campaign/Form/Task/Reserve.php | 27 ++++++++++++++++-------- CRM/Campaign/Page/DashBoard.php | 2 +- CRM/Case/Form/Task/Delete.php | 22 +++++++++++++++---- CRM/Case/Form/Task/Restore.php | 18 +++++++++++++--- CRM/Contribute/Form/Task/Delete.php | 21 ++++++++++++------ CRM/Event/Form/Task/Delete.php | 17 ++++++--------- CRM/Grant/Form/Task/Delete.php | 17 +++++++++++---- CRM/Member/Form/Task/Delete.php | 17 +++++++++++---- CRM/Pledge/Form/Task/Delete.php | 20 ++++++++++++------ 13 files changed, 141 insertions(+), 61 deletions(-) diff --git a/CRM/Activity/Form/Task/AddToTag.php b/CRM/Activity/Form/Task/AddToTag.php index 175a784aa1..b2ebb54af3 100644 --- a/CRM/Activity/Form/Task/AddToTag.php +++ b/CRM/Activity/Form/Task/AddToTag.php @@ -145,9 +145,9 @@ class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task { list($total, $added, $notAdded) = CRM_Core_BAO_EntityTag::addEntitiesToTag($this->_activityHolderIds, $key, 'civicrm_activity'); - $status = array(ts('%count activities tagged', array('count' => $added, 'plural' => '%count activities tagged'))); + $status = array(ts('Activity tagged', array('count' => $added, 'plural' => '%count activities tagged'))); if ($notAdded) { - $status[] = ts('%count activities already had this tag', array( + $status[] = ts('1 activity already had this tag', array( 'count' => $notAdded, 'plural' => '%count activities already had this tag', )); diff --git a/CRM/Activity/Form/Task/Delete.php b/CRM/Activity/Form/Task/Delete.php index 1a899e003b..aa9df7f625 100755 --- a/CRM/Activity/Form/Task/Delete.php +++ b/CRM/Activity/Form/Task/Delete.php @@ -74,16 +74,25 @@ class CRM_Activity_Form_Task_Delete extends CRM_Activity_Form_Task { * @return void */ public function postProcess() { - $deletedActivities = 0; + $deleted = $failed = 0; foreach ($this->_activityHolderIds as $activityId['id']) { $moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']); if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) { - $deletedActivities++; + $deleted++; } + else { + $failed++; + } + } + + if ($deleted) { + $msg = ts('%count activity deleted.', array('plural' => '%count activities deleted.', 'count' => $deleted)); + CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } - CRM_Core_Session::setStatus($deletedActivities, ts('Deleted Activities'), "success"); - CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info"); + if ($failed) { + CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + } } } diff --git a/CRM/Activity/Form/Task/RemoveFromTag.php b/CRM/Activity/Form/Task/RemoveFromTag.php index 26c0e26d3d..37973570e6 100644 --- a/CRM/Activity/Form/Task/RemoveFromTag.php +++ b/CRM/Activity/Form/Task/RemoveFromTag.php @@ -135,7 +135,7 @@ class CRM_Activity_Form_Task_RemoveFromTag extends CRM_Activity_Form_Task { list($total, $removed, $notRemoved) = CRM_Core_BAO_EntityTag::removeEntitiesFromTag($this->_activityHolderIds, $key, 'civicrm_activity'); $status = array( - ts('%count activities un-tagged', array( + ts('%count activity un-tagged', array( 'count' => $removed, 'plural' => '%count activities un-tagged', )), diff --git a/CRM/Campaign/Form/Task/Release.php b/CRM/Campaign/Form/Task/Release.php index 2fe884cb81..d22dbd0374 100644 --- a/CRM/Campaign/Form/Task/Release.php +++ b/CRM/Campaign/Form/Task/Release.php @@ -159,13 +159,23 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task { $query = 'UPDATE civicrm_activity SET is_deleted = 1 WHERE id IN ( ' . implode(', ', $deleteActivityIds) . ' )'; CRM_Core_DAO::executeQuery($query); - $status = array(ts("%1 respondent(s) have been released.", array(1 => count($deleteActivityIds)))); + if ($deleteActivityIds) { + $status = ts("Respondent has been released.", array( + 'count' => count($deleteActivityIds), + 'plural' => '%count respondents have been released.', + )); + CRM_Core_Session::setStatus($status, ts('Released'), 'success'); + } + if (count($this->_contactIds) > count($deleteActivityIds)) { - $status[] = ts("%1 respondents did not release.", - array(1 => (count($this->_contactIds) - count($deleteActivityIds))) + $status = ts('1 respondent did not release.', + array( + 'count' => (count($this->_contactIds) - count($deleteActivityIds)), + 'plural' => '%count respondents did not release.', + ) ); + CRM_Core_Session::setStatus($status, ts('Notice'), 'alert'); } - CRM_Core_Session::setStatus(implode(' ', $status), '', 'info'); } } diff --git a/CRM/Campaign/Form/Task/Reserve.php b/CRM/Campaign/Form/Task/Reserve.php index 852a3466d2..3fd757bfda 100644 --- a/CRM/Campaign/Form/Task/Reserve.php +++ b/CRM/Campaign/Form/Task/Reserve.php @@ -132,16 +132,22 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { $errorMsg = ts('The maximum number of contacts is already reserved for this interviewer.'); } elseif (count($this->_contactIds) > ($maxVoters - $this->_numVoters)) { - $errorMsg = ts('You can reserve a maximum of %1 contact(s) at a time for this survey.', - array(1 => $maxVoters - $this->_numVoters) + $errorMsg = ts('You can reserve a maximum of %count contact at a time for this survey.', + array( + 'plural' => 'You can reserve a maximum of %count contacts at a time for this survey.', + 'count' => $maxVoters - $this->_numVoters, + ) ); } } $defaultNum = CRM_Utils_Array::value('default_number_of_contacts', $this->_surveyDetails); if (!$errorMsg && $defaultNum && (count($this->_contactIds) > $defaultNum)) { - $errorMsg = ts('You can reserve a maximum of %1 contact(s) at a time for this survey.', - array(1 => $defaultNum) + $errorMsg = ts('You can reserve a maximum of %count contact at a time for this survey.', + array( + 'plural' => 'You can reserve a maximum of %count contacts at a time for this survey.', + 'count' => $defaultNum, + ) ); } @@ -276,18 +282,21 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { // Success message if ($countVoters > 0) { - $status = '

' . ts("%1 Contact(s) have been reserved.", array(1 => $countVoters)) . '

'; + $status = '

' . ts("%count contact has been reserved.", array('plural' => '%count contacts have been reserved.', 'count' => $countVoters)) . '

'; if ($groupAdditions) { - $status .= '

' . ts('Respondent(s) has been added to %1 group(s).', - array(1 => implode(', ', $groupAdditions)) + $status .= '

' . ts('They have been added to %1.', + array(1 => implode(' ' . ts('and') . ' ', $groupAdditions)) ) . '

'; } CRM_Core_Session::setStatus($status, ts('Reservation Added'), 'success'); } // Error message if (count($this->_contactIds) > $countVoters) { - CRM_Core_Session::setStatus(ts('Reservation did not add for %1 contact(s).', - array(1 => (count($this->_contactIds) - $countVoters)) + CRM_Core_Session::setStatus(ts('Reservation did not add for %count contact.', + array( + 'plural' => 'Reservation did not add for %count contacts.', + 'count' => (count($this->_contactIds) - $countVoters), + ) ), ts('Notice')); } diff --git a/CRM/Campaign/Page/DashBoard.php b/CRM/Campaign/Page/DashBoard.php index f51bdfc4e0..fe64ba0328 100644 --- a/CRM/Campaign/Page/DashBoard.php +++ b/CRM/Campaign/Page/DashBoard.php @@ -314,7 +314,7 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { $surveysData[$sid]['campaign'] = CRM_Utils_Array::value($campaignId, $campaigns); $surveysData[$sid]['activity_type'] = $surveyType[$survey['activity_type_id']]; if (!empty($survey['release_frequency'])) { - $surveysData[$sid]['release_frequency'] = $survey['release_frequency'] . ' ' . ts('Day(s)'); + $surveysData[$sid]['release_frequency'] = ts('1 Day', array('plural' => '%count Days', 'count' => $survey['release_frequency'])); } $action = array_sum(array_keys(self::surveyActionLinks($surveysData[$sid]['activity_type']))); diff --git a/CRM/Case/Form/Task/Delete.php b/CRM/Case/Form/Task/Delete.php index 0579065f90..f3d0f8cb3c 100644 --- a/CRM/Case/Form/Task/Delete.php +++ b/CRM/Case/Form/Task/Delete.php @@ -80,15 +80,29 @@ class CRM_Case_Form_Task_Delete extends CRM_Case_Form_Task { * @return void */ public function postProcess() { - $deletedCases = 0; + $deleted = $failed = 0; foreach ($this->_caseIds as $caseId) { if (CRM_Case_BAO_Case::deleteCase($caseId, $this->_moveToTrash)) { - $deletedCases++; + $deleted++; } + else { + $failed++; + } + } + + if ($deleted) { + if ($this->_moveToTrash) { + $msg = ts('%count case moved to trash.', array('plural' => '%count cases moved to trash.', 'count' => $deleted)); + } + else { + $msg = ts('%count case permanently deleted.', array('plural' => '%count cases permanently deleted.', 'count' => $deleted)); + } + CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } - CRM_Core_Session::setStatus($deletedCases, ts('Deleted Cases'), 'success'); - CRM_Core_Session::setStatus('', ts('Total Selected Case(s): %1', array(1 => count($this->_caseIds))), 'info'); + if ($failed) { + CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + } } } diff --git a/CRM/Case/Form/Task/Restore.php b/CRM/Case/Form/Task/Restore.php index dfbfa985b1..8f773ceee9 100644 --- a/CRM/Case/Form/Task/Restore.php +++ b/CRM/Case/Form/Task/Restore.php @@ -74,15 +74,27 @@ class CRM_Case_Form_Task_Restore extends CRM_Case_Form_Task { * @return void */ public function postProcess() { - $restoredCases = 0; + $restoredCases = $failed = 0; foreach ($this->_caseIds as $caseId) { if (CRM_Case_BAO_Case::restoreCase($caseId)) { $restoredCases++; } + else { + $failed++; + } + } + + if ($restoredCases) { + $msg = ts('%count case restored from trash.', array( + 'plural' => '%count cases restored from trash.', + 'count' => $restoredCases, + )); + CRM_Core_Session::setStatus($msg, ts('Restored'), 'success'); } - CRM_Core_Session::setStatus($restoredCases, ts('Restored Cases'), 'success'); - CRM_Core_Session::setStatus('', ts('Total Selected Case(s): %1', array(1 => count($this->_caseIds))), 'info'); + if ($failed) { + CRM_Core_Session::setStatus(ts('1 could not be restored.', array('plural' => '%count could not be restored.', 'count' => $failed)), ts('Error'), 'error'); + } } } diff --git a/CRM/Contribute/Form/Task/Delete.php b/CRM/Contribute/Form/Task/Delete.php index 5b19e4cdbc..06fc3eff07 100644 --- a/CRM/Contribute/Form/Task/Delete.php +++ b/CRM/Contribute/Form/Task/Delete.php @@ -78,17 +78,24 @@ class CRM_Contribute_Form_Task_Delete extends CRM_Contribute_Form_Task { * @return void */ public function postProcess() { - $deletedContributions = 0; + $deleted = $failed = 0; foreach ($this->_contributionIds as $contributionId) { if (CRM_Contribute_BAO_Contribution::deleteContribution($contributionId)) { - $deletedContributions++; + $deleted++; } + else { + $failed++; + } + } + + if ($deleted) { + $msg = ts('%count contribution deleted.', array('plural' => '%count contributions deleted.', 'count' => $deleted)); + CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); + } + + if ($failed) { + CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); } - $status = ts('Deleted Contribution(s): %1 (Total Selected: %2) ', array( - 1 => $deletedContributions, - 2 => count($this->_contributionIds), - )); - CRM_Core_Session::setStatus($status, '', 'info'); } } diff --git a/CRM/Event/Form/Task/Delete.php b/CRM/Event/Form/Task/Delete.php index a2c11055d4..7dfc462beb 100644 --- a/CRM/Event/Form/Task/Delete.php +++ b/CRM/Event/Form/Task/Delete.php @@ -123,18 +123,13 @@ class CRM_Event_Form_Task_Delete extends CRM_Event_Form_Task { $deletedParticipants += $additionalCount; } - $status = array( - ts('Participant(s) Deleted: %1 (Total Selected: %2)', array( - 1 => $deletedParticipants, - 2 => count($this->_participantIds), - )), - ); - if (!empty($participantLinks)) { - $status[] = ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') . '
' . $participantLinks; - } - foreach ($status as $text) { - CRM_Core_Session::setStatus($text, '', 'info'); + $status = ts('%count participant deleted.', array('plural' => '%count participants deleted.', 'count' => $deletedParticipants)); + + if ($participantLinks) { + $status .= '

' . ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') + . '

' . $participantLinks; } + CRM_Core_Session::setStatus($status, ts('Removed'), 'info'); } } diff --git a/CRM/Grant/Form/Task/Delete.php b/CRM/Grant/Form/Task/Delete.php index 18703ab2cc..d3b4680c18 100644 --- a/CRM/Grant/Form/Task/Delete.php +++ b/CRM/Grant/Form/Task/Delete.php @@ -79,15 +79,24 @@ class CRM_Grant_Form_Task_Delete extends CRM_Grant_Form_Task { * @return void */ public function postProcess() { - $deletedGrants = 0; + $deleted = $failed = 0; foreach ($this->_grantIds as $grantId) { if (CRM_Grant_BAO_Grant::del($grantId)) { - $deletedGrants++; + $deleted++; } + else { + $failed++; + } + } + + if ($deleted) { + $msg = ts('%count grant deleted.', array('plural' => '%count grants deleted.', 'count' => $deleted)); + CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } - CRM_Core_Session::setStatus(ts('Deleted Grant(s): %1', array(1 => $deletedGrants)), '', 'info'); - CRM_Core_Session::setStatus(ts('Total Selected Grant(s): %1', array(1 => count($this->_grantIds))), '', 'info'); + if ($failed) { + CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + } } } diff --git a/CRM/Member/Form/Task/Delete.php b/CRM/Member/Form/Task/Delete.php index a661a50ba5..cb6ab91efd 100644 --- a/CRM/Member/Form/Task/Delete.php +++ b/CRM/Member/Form/Task/Delete.php @@ -78,15 +78,24 @@ class CRM_Member_Form_Task_Delete extends CRM_Member_Form_Task { * @return void */ public function postProcess() { - $deletedMembers = 0; + $deleted = $failed = 0; foreach ($this->_memberIds as $memberId) { if (CRM_Member_BAO_Membership::del($memberId)) { - $deletedMembers++; + $deleted++; } + else { + $failed++; + } + } + + if ($deleted) { + $msg = ts('%count membership deleted.', array('plural' => '%count memberships deleted.', 'count' => $deleted)); + CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } - CRM_Core_Session::setStatus($deletedMembers, ts('Deleted Membership(s)'), 'success'); - CRM_Core_Session::setStatus(ts('Total Selected Membership(s): %1', array(1 => count($this->_memberIds))), '', 'info'); + if ($failed) { + CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + } } } diff --git a/CRM/Pledge/Form/Task/Delete.php b/CRM/Pledge/Form/Task/Delete.php index 2bca8215a5..f67636aaf4 100644 --- a/CRM/Pledge/Form/Task/Delete.php +++ b/CRM/Pledge/Form/Task/Delete.php @@ -76,18 +76,24 @@ class CRM_Pledge_Form_Task_Delete extends CRM_Pledge_Form_Task { * @return void */ public function postProcess() { - $deletedPledges = 0; + $deleted = $failed = 0; foreach ($this->_pledgeIds as $pledgeId) { if (CRM_Pledge_BAO_Pledge::deletePledge($pledgeId)) { - $deletedPledges++; + $deleted++; } + else { + $failed++; + } + } + + if ($deleted) { + $msg = ts('%count pledge deleted.', array('plural' => '%count pledges deleted.', 'count' => $deleted)); + CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } - $status = ts('Deleted Pledge(s): %1 (Total Selected: %2) ', array( - 1 => $deletedPledges, - 2 => count($this->_pledgeIds), - )); - CRM_Core_Session::setStatus($status, '', 'info'); + if ($failed) { + CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + } } } -- 2.25.1