diff --git a/CRM/Civicase/Hook/BuildForm/CaseCategoryFormLabelTranslationForChangeCase.php b/CRM/Civicase/Hook/BuildForm/CaseCategoryFormLabelTranslationForChangeCase.php index 513bc17ca..d827326bb 100644 --- a/CRM/Civicase/Hook/BuildForm/CaseCategoryFormLabelTranslationForChangeCase.php +++ b/CRM/Civicase/Hook/BuildForm/CaseCategoryFormLabelTranslationForChangeCase.php @@ -1,5 +1,7 @@ getLabel(); + $label = CaseTypeCategoryHelper::translate($element->getLabel()); $element->setLabel($label); } diff --git a/CRM/Civicase/Hook/BuildForm/CaseCategoryFormLabelTranslationForNewCase.php b/CRM/Civicase/Hook/BuildForm/CaseCategoryFormLabelTranslationForNewCase.php index 1ca7c4c8c..71212498a 100644 --- a/CRM/Civicase/Hook/BuildForm/CaseCategoryFormLabelTranslationForNewCase.php +++ b/CRM/Civicase/Hook/BuildForm/CaseCategoryFormLabelTranslationForNewCase.php @@ -52,7 +52,7 @@ private function translateFormLabels(CRM_Core_Form $form) { */ private function translateLabel(array $elements) { foreach ($elements as $element) { - $label = $element->getLabel(); + $label = CaseTypeCategoryHelper::translate($element->getLabel()); $element->setLabel($label); } } diff --git a/CRM/Civicase/Hook/Helper/CaseTypeCategory.php b/CRM/Civicase/Hook/Helper/CaseTypeCategory.php index 1d83e46d4..9879ee617 100644 --- a/CRM/Civicase/Hook/Helper/CaseTypeCategory.php +++ b/CRM/Civicase/Hook/Helper/CaseTypeCategory.php @@ -1,5 +1,6 @@ get($caseCategoryWebformUrl) : NULL; } + /** + * This is wrapper for "E::ts" function. + * + * CiviCRM does not recomment to use this to translate variables. + * But in CiviCase, we have used this function in few places with variables + * to achieve certain results. + * Hence this new function has been created, so that it can be only used in + * the places where it is absolutely necessary. + * + * @param string $value + * Value to be translated. + * + * @return string + * Translated value. + */ + public static function translate($value) { + return E::ts($value); + } + } diff --git a/CRM/Civicase/Hook/PreProcess/CaseCategoryWordReplacementsForChangeCase.php b/CRM/Civicase/Hook/PreProcess/CaseCategoryWordReplacementsForChangeCase.php index d163dadeb..aeef2f944 100644 --- a/CRM/Civicase/Hook/PreProcess/CaseCategoryWordReplacementsForChangeCase.php +++ b/CRM/Civicase/Hook/PreProcess/CaseCategoryWordReplacementsForChangeCase.php @@ -1,6 +1,7 @@ get_template_vars('activityTypeName'); + $pageTitle = CaseTypeCategoryHelper::translate($form->get_template_vars('activityTypeName')); $displayName = $this->getContactDisplayName($form); if ($displayName) { CRM_Utils_System::setTitle($displayName . ' - ' . $pageTitle); diff --git a/CRM/Civicase/Hook/PreProcess/CaseCategoryWordReplacementsForNewCase.php b/CRM/Civicase/Hook/PreProcess/CaseCategoryWordReplacementsForNewCase.php index 25561ff73..a557cf13c 100644 --- a/CRM/Civicase/Hook/PreProcess/CaseCategoryWordReplacementsForNewCase.php +++ b/CRM/Civicase/Hook/PreProcess/CaseCategoryWordReplacementsForNewCase.php @@ -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($pageTitle); + CRM_Utils_System::setTitle(CaseTypeCategoryHelper::translate($pageTitle)); CaseCategoryHelper::updateBreadcrumbs($caseCategoryId); } diff --git a/CRM/Civicase/Hook/Tokens/AddContactTokens.php b/CRM/Civicase/Hook/Tokens/AddContactTokens.php index 37176c413..a1be080c4 100644 --- a/CRM/Civicase/Hook/Tokens/AddContactTokens.php +++ b/CRM/Civicase/Hook/Tokens/AddContactTokens.php @@ -1,6 +1,6 @@ contactFieldsService->get() as $field) { $tokens[self::TOKEN_KEY]['current_user.contact_' . $field] = - E::ts('Current User ') . ucwords(str_replace("_", " ", $field)); + CaseTypeCategoryHelper::translate('Current User ' . ucwords(str_replace("_", " ", $field))); } foreach ($this->contactCustomFieldsService->get() as $key => $field) { $tokens[self::TOKEN_KEY]['current_user.contact_' . $key] = - E::ts('Current User ') . ucwords(str_replace("_", " ", $field)); + CaseTypeCategoryHelper::translate('Current User ' . ucwords(str_replace("_", " ", $field))); } }