Skip to content

Commit

Permalink
Fix ts() namespace in searchKit & afform extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Mar 5, 2021
1 parent 90d9e73 commit 1e88107
Show file tree
Hide file tree
Showing 44 changed files with 60 additions and 52 deletions.
3 changes: 2 additions & 1 deletion ext/afform/admin/CRM/AfformAdmin/Page/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
use CRM_AfformAdmin_ExtensionUtil as E;

/**
* Base page for Afform admin
Expand All @@ -16,7 +17,7 @@ class CRM_AfformAdmin_Page_Base extends CRM_Core_Page {

public function run() {
$breadCrumb = [
'title' => ts('Form Builder'),
'title' => E::ts('Form Builder'),
'url' => CRM_Utils_System::url('civicrm/admin/afform', NULL, FALSE, '/'),
];
CRM_Utils_System::appendBreadCrumb([$breadCrumb]);
Expand Down
8 changes: 4 additions & 4 deletions ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public static function getAdminSettings() {
->execute();
// Pluralize tabs (too bad option groups only store a single label)
$plurals = [
'form' => ts('Custom Forms'),
'search' => ts('Search Displays'),
'block' => ts('Field Blocks'),
'system' => ts('System Forms'),
'form' => E::ts('Custom Forms'),
'search' => E::ts('Search Displays'),
'block' => E::ts('Field Blocks'),
'system' => E::ts('System Forms'),
];
foreach ($afformTypes as $index => $type) {
$afformTypes[$index]['plural'] = $plurals[$type['name']] ?? \CRM_Utils_String::pluralize($type['label']);
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/admin/ang/afAdmin/afAdminList.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"use strict";

angular.module('afAdmin').controller('afAdminList', function($scope, afforms, crmApi4, crmStatus) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = $scope.$ctrl = this;

$scope.crmUrl = CRM.url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
templateUrl: '~/afGuiEditor/afGuiEditOptions.html',
require: {field: '^^afGuiField'},
controller: function($scope) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = this;

this.$onInit = function() {
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/admin/ang/afGuiEditor/afGuiEditor.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
controllerAs: 'editor',
controller: function($scope, crmApi4, afGui, $parse, $timeout, $location) {
var ts = $scope.ts = CRM.ts('afform');
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin');
$scope.crmUrl = CRM.url;

$scope.afform = null;
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/admin/ang/afGuiEditor/afGuiEntity.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
require: {editor: '^^afGuiEditor'},
controller: function ($scope, $timeout, afGui) {
var ts = $scope.ts = CRM.ts();
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin');
var ctrl = this;
$scope.controls = {};
$scope.fieldList = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
require: 'ngModel',
link: function (scope, element, attrs, ctrl) {
var ts = scope.ts = CRM.ts(),
var ts = scope.ts = CRM.ts('org.civicrm.afform_admin'),
multi;

function destroyWidget() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
node: '='
},
controller: function($scope, afGui) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = this;

$scope.getSetBackgroundColor = function(color) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
node: '='
},
controller: function($scope, afGui) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = this;

$scope.getSetBorderWidth = function(width) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"use strict";

angular.module('afGuiEditor').controller('afGuiSaveBlock', function($scope, crmApi4, dialogService) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
model = $scope.model,
original = $scope.original = {
title: model.title,
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/admin/ang/afGuiEditor/afGuiSearch.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
require: {editor: '^^afGuiEditor'},
controller: function ($scope, $timeout, afGui) {
var ts = $scope.ts = CRM.ts();
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin');
var ctrl = this;
$scope.controls = {};
$scope.fieldList = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
deleteThis: '&'
},
controller: function($scope, afGui) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = this;

// TODO: Add action selector to UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
require: {editor: '^^afGuiEditor'},
controller: function($scope, crmApi4, dialogService, afGui) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = this;

this.$onInit = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
container: '^^afGuiContainer'
},
controller: function($scope, afGui) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = this;

$scope.editingOptions = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
deleteThis: '&'
},
controller: function($scope, $sce, $timeout) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = this;

this.$onInit = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
node: '='
},
controller: function($scope, afGui) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = this;

this.$onInit = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
deleteThis: '&'
},
controller: function($scope, afGui) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = this;

$scope.tags = {
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/core/CRM/Afform/Page/AfformBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function run() {

// If the user has "access civicrm" append home breadcrumb
if (CRM_Core_Permission::check('access CiviCRM')) {
CRM_Utils_System::appendBreadCrumb([['title' => ts('CiviCRM'), 'url' => CRM_Utils_System::url('civicrm')]]);
CRM_Utils_System::appendBreadCrumb([['title' => E::ts('CiviCRM'), 'url' => CRM_Utils_System::url('civicrm')]]);
// If the user has "admin civicrm" & the admin extension is enabled
if (CRM_Core_Permission::check('administer CiviCRM') && CRM_Utils_Array::findAll(
\CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles(),
Expand Down
6 changes: 4 additions & 2 deletions ext/afform/core/Civi/Afform/AfformMetadataInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Civi\Afform;

use CRM_Afform_ExtensionUtil as E;

/**
* Class AfformMetadataInjector
* @package Civi\Afform
Expand Down Expand Up @@ -109,13 +111,13 @@ private static function fillFieldMetadata($entityName, $action, \DOMElement $afF
}
// Default placeholder for select inputs
if ($fieldInfo['input_type'] === 'Select') {
$fieldInfo['input_attrs'] = ($fieldInfo['input_attrs'] ?? []) + ['placeholder' => ts('Select')];
$fieldInfo['input_attrs'] = ($fieldInfo['input_attrs'] ?? []) + ['placeholder' => E::ts('Select')];
}

$fieldDefn = $existingFieldDefn ? \CRM_Utils_JS::getRawProps($existingFieldDefn) : [];

if ('Date' === $fieldInfo['input_type'] && !empty($fieldDefn['input_type']) && \CRM_Utils_JS::decode($fieldDefn['input_type']) === 'Select') {
$fieldInfo['input_attrs']['placeholder'] = ts('Select');
$fieldInfo['input_attrs']['placeholder'] = E::ts('Select');
$fieldInfo['options'] = \CRM_Utils_Array::makeNonAssociative(\CRM_Core_OptionGroup::values('relative_date_filters'), 'id', 'label');
}

Expand Down
3 changes: 2 additions & 1 deletion ext/afform/core/Civi/Api4/Action/Afform/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Civi\Api4\CustomField;
use Civi\Api4\CustomGroup;
use CRM_Afform_ExtensionUtil as E;

/**
* @inheritDoc
Expand Down Expand Up @@ -126,7 +127,7 @@ protected function getAutoGenerated(&$names, $toGet, $getLayout) {
'name' => $name,
'type' => 'block',
'requires' => [],
'title' => ts('%1 block (default)', [1 => $custom['title']]),
'title' => E::ts('%1 block (default)', [1 => $custom['title']]),
'description' => '',
'is_dashlet' => FALSE,
'is_public' => FALSE,
Expand Down
6 changes: 3 additions & 3 deletions ext/afform/core/afform.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
function _afform_fields_filter($params) {
$result = [];
$fields = \Civi\Api4\Afform::getfields()->setCheckPermissions(FALSE)->setAction('create')->execute()->indexBy('name');
$fields = \Civi\Api4\Afform::getfields(FALSE)->setAction('create')->execute()->indexBy('name');
foreach ($fields as $fieldName => $field) {
if (isset($params[$fieldName])) {
$result[$fieldName] = $params[$fieldName];
Expand Down Expand Up @@ -156,7 +156,7 @@ function afform_civicrm_managed(&$entities) {
'domain_id' => CRM_Core_BAO_Domain::getDomain()->id,
'is_active' => TRUE,
'name' => $afform['name'],
'label' => $afform['title'] ?? ts('(Untitled)'),
'label' => $afform['title'] ?? E::ts('(Untitled)'),
'directive' => _afform_angular_module_name($afform['name'], 'dash'),
'permission' => "@afform:" . $afform['name'],
],
Expand Down Expand Up @@ -348,7 +348,7 @@ function afform_civicrm_permissionList(&$permissions) {
foreach ($scanner->getMetas() as $name => $meta) {
$permissions['@afform:' . $name] = [
'group' => 'afform',
'title' => ts('Afform: Inherit permission of %1', [
'title' => E::ts('Afform: Inherit permission of %1', [
1 => $name,
]),
];
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/core/ang/af/afField.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
defn: '='
},
controller: function($scope, $element, crmApi4) {
var ts = $scope.ts = CRM.ts('afform'),
var ts = $scope.ts = CRM.ts('org.civicrm.afform'),
ctrl = this,
boolOptions = [{id: true, label: ts('Yes')}, {id: false, label: ts('No')}],
// Only used for is_primary radio button
Expand Down
4 changes: 3 additions & 1 deletion ext/search/CRM/Search/Page/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
+--------------------------------------------------------------------+
*/

use CRM_Search_ExtensionUtil as E;

/**
* Angular base page for search admin
*/
class CRM_Search_Page_Admin extends CRM_Core_Page {

public function run() {
$breadCrumb = [
'title' => ts('Search Kit'),
'title' => E::ts('Search Kit'),
'url' => CRM_Utils_System::url('civicrm/admin/search', NULL, FALSE, '/list'),
];
CRM_Utils_System::appendBreadCrumb([$breadCrumb]);
Expand Down
8 changes: 5 additions & 3 deletions ext/search/Civi/Search/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Civi\Search;

use CRM_Search_ExtensionUtil as E;

/**
* Class Tasks
* @package Civi\Search
Expand Down Expand Up @@ -47,7 +49,7 @@ public static function getTasks():array {
// Note: the placeholder %1 will be replaced with entity name on the clientside
$tasks = [
'export' => [
'title' => ts('Export %1'),
'title' => E::ts('Export %1'),
'icon' => 'fa-file-excel-o',
'entities' => array_keys(\CRM_Export_BAO_Export::getComponents()),
'crmPopup' => [
Expand All @@ -56,13 +58,13 @@ public static function getTasks():array {
],
],
'update' => [
'title' => ts('Update %1'),
'title' => E::ts('Update %1'),
'icon' => 'fa-save',
'entities' => [],
'uiDialog' => ['templateUrl' => '~/crmSearchActions/crmSearchActionUpdate.html'],
],
'delete' => [
'title' => ts('Delete %1'),
'title' => E::ts('Delete %1'),
'icon' => 'fa-trash',
'entities' => [],
'uiDialog' => ['templateUrl' => '~/crmSearchActions/crmSearchActionDelete.html'],
Expand Down
2 changes: 1 addition & 1 deletion ext/search/ang/crmSearchActions/SaveSmartGroup.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"use strict";

angular.module('crmSearchActions').controller('SaveSmartGroup', function ($scope, $element, $timeout, crmApi4, dialogService, searchMeta) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
model = $scope.model;
$scope.groupEntityRefParams = {
entity: 'Group',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"use strict";

angular.module('crmSearchActions').controller('crmSearchActionDelete', function($scope, dialogService) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
model = $scope.model,
ctrl = $scope.$ctrl = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"use strict";

angular.module('crmSearchActions').controller('crmSearchActionUpdate', function ($scope, $timeout, crmApi4, dialogService) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
model = $scope.model,
ctrl = $scope.$ctrl = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
templateUrl: '~/crmSearchActions/crmSearchActions.html',
controller: function($scope, crmApi4, dialogService) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
ctrl = this,
initialized = false,
unwatchIDs = $scope.$watch('$ctrl.ids.length', watchIDs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
templateUrl: '~/crmSearchActions/crmSearchBatchRunner.html',
controller: function($scope, $timeout, $interval, crmApi4) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
ctrl = this,
currentBatch = 0,
totalBatches,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
require: {ngModel: 'ngModel'},
templateUrl: '~/crmSearchActions/crmSearchInput/crmSearchInput.html',
controller: function($scope) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
ctrl = this;

this.isMulti = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require: {ngModel: 'ngModel'},
template: '<div class="form-group" ng-include="$ctrl.getTemplate()"></div>',
controller: function($scope, formatForSelect2) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
ctrl = this;

this.$onInit = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
restrict: 'A',
controller: function ($scope, $element, dialogService) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
ctrl = this;

$scope.saveGroup = function () {
Expand Down
2 changes: 1 addition & 1 deletion ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
templateUrl: '~/crmSearchAdmin/crmSearchAdmin.html',
controller: function($scope, $element, $location, $timeout, crmApi4, dialogService, searchMeta, formatForSelect2) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
ctrl = this;

this.DEFAULT_AGGREGATE_FN = 'GROUP_CONCAT';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
return html;
},
controller: function($scope, $timeout, searchMeta) {
var ts = $scope.ts = CRM.ts(),
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
ctrl = this;

this.preview = this.stale = false;
Expand Down
Loading

0 comments on commit 1e88107

Please sign in to comment.