Skip to content

Commit

Permalink
CPS-432: Fix ts function usage
Browse files Browse the repository at this point in the history
  • Loading branch information
deb1990 committed May 28, 2021
1 parent b3482f7 commit b07db52
Show file tree
Hide file tree
Showing 11 changed files with 2,701 additions and 329 deletions.
172 changes: 87 additions & 85 deletions CRM/Civicase/Form/Report/ColumnDefinitionTrait.php

Large diffs are not rendered by default.

446 changes: 223 additions & 223 deletions CRM/Civicase/Form/Report/ExtendedReport.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private function translateFormLabels(CRM_Core_Form $form) {
* For Elements array.
*/
private function translateLabel($element) {
$label = ts($element->getLabel());
$label = $element->getLabel();
$element->setLabel($label);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private function translateFormLabels(CRM_Core_Form $form) {
*/
private function translateLabel(array $elements) {
foreach ($elements as $element) {
$label = ts($element->getLabel());
$label = $element->getLabel();
$element->setLabel($label);
}
}
Expand Down
7 changes: 4 additions & 3 deletions CRM/Civicase/Hook/Permissions/CaseCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use CRM_Civicase_Helper_CaseCategory as CaseCategoryHelper;

/**
* Class CRM_Civicase_Hook_Permissions_CaseCategory.
* Case Category Permissions hook.
*/
class CRM_Civicase_Hook_Permissions_CaseCategory {

Expand All @@ -27,6 +27,7 @@ class CRM_Civicase_Hook_Permissions_CaseCategory {
* CRM_Civicase_Hook_Permissions_CaseCategory constructor.
*
* @param array $permissions
* Permissions.
*/
public function __construct(array &$permissions) {
$this->permissions = &$permissions;
Expand Down Expand Up @@ -55,7 +56,7 @@ private function addCivicaseDefaultPermissions() {
$caseCategoryPermissions = $this->permissionService->get();
$this->permissions[$caseCategoryPermissions['BASIC_CASE_CATEGORY_INFO']['name']] = [
$caseCategoryPermissions['BASIC_CASE_CATEGORY_INFO']['label'],
ts($caseCategoryPermissions['BASIC_CASE_CATEGORY_INFO']['description']),
$caseCategoryPermissions['BASIC_CASE_CATEGORY_INFO']['description'],
];
}

Expand All @@ -76,7 +77,7 @@ private function addCaseCategoryPermissions() {
foreach ($caseCategoryPermissions as $caseCategoryPermission) {
$this->permissions[$caseCategoryPermission['name']] = [
$caseCategoryPermission['label'],
ts($caseCategoryPermission['description']),
$caseCategoryPermission['description'],
];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function addWordReplacements(CRM_Core_Form $form) {
* Form Object.
*/
private function setPageTitle(CRM_Core_Form $form) {
$pageTitle = ts($form->get_template_vars('activityTypeName'));
$pageTitle = $form->get_template_vars('activityTypeName');
$displayName = $this->getContactDisplayName($form);
if ($displayName) {
CRM_Utils_System::setTitle($displayName . ' - ' . $pageTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private function addWordReplacements(CRM_Core_Form $form, $caseCategoryId) {
// We need to translate this manually as Civi does not the page title
// through the ts function.
$pageTitle = $form->get_template_vars('activityType');
CRM_Utils_System::setTitle(ts($pageTitle));
CRM_Utils_System::setTitle($pageTitle);
CaseCategoryHelper::updateBreadcrumbs($caseCategoryId);
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Civicase/Hook/Tabset/CaseCategoryTabAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private function addCaseCategoryContactTabs(array &$tabs, $contactID, &$useAng)
'cid' => $contactID,
'case_type_category' => $caseCategory['value'],
]),
'title' => ts($caseCategory['label']),
'title' => $caseCategory['label'],
'weight' => $caseTabWeight,
'count' => CaseCategoryHelper::getCaseCount($caseCategory['name'], $contactID),
'class' => 'livePage',
Expand Down
6 changes: 4 additions & 2 deletions CRM/Civicase/Hook/Tokens/AddContactTokens.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use CRM_Civicase_ExtensionUtil as E;

/**
* Add current user tokens.
*/
Expand Down Expand Up @@ -50,11 +52,11 @@ public function __construct(
public function run(array &$tokens) {
foreach ($this->contactFieldsService->get() as $field) {
$tokens[self::TOKEN_KEY]['current_user.contact_' . $field] =
ts('Current User ' . ucwords(str_replace("_", " ", $field)));
E::ts('Current User ') . ucwords(str_replace("_", " ", $field));
}
foreach ($this->contactCustomFieldsService->get() as $key => $field) {
$tokens[self::TOKEN_KEY]['current_user.contact_' . $key] =
ts('Current User ' . ucwords(str_replace("_", " ", $field)));
E::ts('Current User ') . ucwords(str_replace("_", " ", $field));
}
}

Expand Down
25 changes: 14 additions & 11 deletions CRM/Civicase/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use CRM_Civicase_Setup_AddManageWorkflowMenu as AddManageWorkflowMenu;
use CRM_Civicase_Service_CaseCategoryInstance as CaseCategoryInstance;
use CRM_Civicase_Helper_CaseUrl as CaseUrlHelper;
use CRM_Civicase_ExtensionUtil as E;

/**
* Collection of upgrade steps.
Expand Down Expand Up @@ -150,7 +151,7 @@ public function install() {
*/
private function createManageCasesMenuItem() {
$this->addNav([
'label' => ts('Manage Cases', ['domain' => 'uk.co.compucorp.civicase']),
'label' => E::ts('Manage Cases'),
'name' => 'Manage Cases',
'url' => CaseUrlHelper::getUrlByRouteType('all'),
'permission' => 'access my cases and activities,access all cases and activities',
Expand Down Expand Up @@ -299,47 +300,47 @@ private function addAllOptionValues() {
// Create activity types.
$this->addOptionValue([
'option_group_id' => 'activity_type',
'label' => ts('Alert'),
'label' => E::ts('Alert'),
'name' => 'Alert',
'grouping' => 'alert',
'is_reserved' => 0,
'description' => ts('Alerts to display in cases'),
'description' => E::ts('Alerts to display in cases'),
'component_id' => 'CiviCase',
'icon' => 'fa-exclamation',
]);
$this->addOptionValue([
'option_group_id' => 'activity_type',
'label' => ts('File Upload'),
'label' => E::ts('File Upload'),
'name' => 'File Upload',
'grouping' => 'file',
'is_reserved' => 0,
'description' => ts('Add files to a case'),
'description' => E::ts('Add files to a case'),
'component_id' => 'CiviCase',
'icon' => 'fa-file',
]);
$this->addOptionValue([
'option_group_id' => 'activity_type',
'label' => ts('Remove Client From Case'),
'label' => E::ts('Remove Client From Case'),
'name' => 'Remove Client From Case',
'grouping' => 'system',
'is_reserved' => 0,
'description' => ts('Client removed from multi-client case'),
'description' => E::ts('Client removed from multi-client case'),
'component_id' => 'CiviCase',
'icon' => 'fa-user-times',
]);

// Create activity statuses.
$this->addOptionValue([
'option_group_id' => 'activity_status',
'label' => ts('Unread'),
'label' => E::ts('Unread'),
'name' => 'Unread',
'grouping' => 'communication',
'is_reserved' => 0,
'color' => '#d9534f',
]);
$this->addOptionValue([
'option_group_id' => 'activity_status',
'label' => ts('Draft'),
'label' => E::ts('Draft'),
'name' => 'Draft',
'grouping' => 'communication',
'is_reserved' => 0,
Expand Down Expand Up @@ -498,8 +499,10 @@ public function enqueuePendingRevisions(CRM_Queue_Queue $queue) {
if ($revisionNum <= $currentRevisionNum) {
continue;
}
$tsParams = [1 => $this->extensionName, 2 => $revisionNum];
$title = ts('Upgrade %1 to revision %2', $tsParams);
$title = E::ts('Upgrade %1 to revision %2', [
1 => $this->extensionName,
2 => $revisionNum,
]);
$upgradeTask = new CRM_Queue_Task(
[get_class($this), 'runStepUpgrade'],
[(new $revisionClass())],
Expand Down
Loading

0 comments on commit b07db52

Please sign in to comment.