Skip to content

hook_civicrm_permission: fix incorrect 'ts' usage.

homotechsual requested to merge github/fork/mlutfy/hookPermTs into master

Created by: mlutfy

Fixes/improves a few things:

  • ts() usage in the $prefix: punctuation can be localized, ex: in French, there is a non-breaking space before a column.
  • In the Civimonitoring example, use E::ts instead. I only did it here, since I could clearly show the use CRM_Civimonitoring_ExtensionUtil as E without cluttering too much.
  • updated the array syntax, because it's not 1995 anymore.

I tried to keep it simple, but the actual "correct" ts usage for this example:

// WRONG:
            $prefix = ts('CiviCRM Grant Program:') . ' ';
            $permissions['edit grant programs'] = [
              $prefix . ts('edit grant programs'),                     // label
              ts('Create or edit grant programs and their criteria'),  // description
            ];

should be:

            $permissions['edit grant programs'] = [
              E::ts('CiviCRM Grant Program: %1', [1 => E::ts('edit grant programs')]),
              E::ts('Create or edit grant programs and their criteria'),
            ];

.. but that this would give most people a headache and they just won't use it.

Merge request reports