From 3e524abc661d401c55ec8b3439a0125eae0f088d Mon Sep 17 00:00:00 2001
From: Matthieu Aubry <mattab@users.noreply.github.com>
Date: Thu, 1 Dec 2016 09:46:06 +1300
Subject: [PATCH] Use placeholder in translation string (#10924)

* Use placeholder in translation string

* Fix the system test
---
 core/UrlHelper.php                                            | 4 ++--
 plugins/SitesManager/lang/en.json                             | 2 +-
 .../templates/help/excluded-query-parameters-help.html        | 2 +-
 plugins/WebsiteMeasurable/MeasurableSettings.php              | 2 +-
 ..._apiGetReportMetadata__API.getAvailableMeasurableTypes.xml | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/core/UrlHelper.php b/core/UrlHelper.php
index ae4f3c622d..f9d2bac83e 100644
--- a/core/UrlHelper.php
+++ b/core/UrlHelper.php
@@ -27,7 +27,7 @@ class UrlHelper
     *
     * @return true if $test matches or is equal to one of the regex/string in $patterns, false otherwise.
     */
-    protected static function in_array_reg($test, $patterns)
+    protected static function in_array_matches_regex($test, $patterns)
     {
         foreach($patterns as $val) {
             if(@preg_match($val, null) === false) {
@@ -62,7 +62,7 @@ class UrlHelper
             // decode encoded square brackets
             $name = str_replace(array('%5B', '%5D'), array('[', ']'), $name);
 
-            if (!self::in_array_reg(strtolower($name), $parametersToExclude)) {
+            if (!self::in_array_matches_regex(strtolower($name), $parametersToExclude)) {
                 if (is_array($value)) {
                     foreach ($value as $param) {
                         if ($param === false) {
diff --git a/plugins/SitesManager/lang/en.json b/plugins/SitesManager/lang/en.json
index 56a812a434..898b257a82 100644
--- a/plugins/SitesManager/lang/en.json
+++ b/plugins/SitesManager/lang/en.json
@@ -43,7 +43,7 @@
         "KeepURLFragmentsLong": "Keep Page URL fragments when tracking Page URLs",
         "ListOfIpsToBeExcludedOnAllWebsites": "The IPs below will be excluded from being tracked on all websites.",
         "ListOfQueryParametersToBeExcludedOnAllWebsites": "The Query URLs parameters below will be excluded from URLs on all websites.",
-        "ListOfQueryParametersToExclude": "Enter the list of URL Query Parameters, one per line, to exclude from the Page URLs reports. Regular expressions such as /^sess.*|.*[dD]ate$/ are suported.",
+        "ListOfQueryParametersToExclude": "Enter the list of URL Query Parameters, one per line, to exclude from the Page URLs reports. Regular expressions such as %s are suported.",
         "MainDescription": "Your Web Analytics reports need Websites! Add, update, delete Websites, and show the JavaScript to insert in your pages.",
         "MenuManage": "Manage",
         "NotAnEcommerceSite": "Not an Ecommerce site",
diff --git a/plugins/SitesManager/templates/help/excluded-query-parameters-help.html b/plugins/SitesManager/templates/help/excluded-query-parameters-help.html
index 39fed1cf89..c316c38737 100644
--- a/plugins/SitesManager/templates/help/excluded-query-parameters-help.html
+++ b/plugins/SitesManager/templates/help/excluded-query-parameters-help.html
@@ -1,5 +1,5 @@
 <div>
-    {{ 'SitesManager_ListOfQueryParametersToExclude'|translate }}
+    {{ 'SitesManager_ListOfQueryParametersToExclude'|translate:'/^sess.*|.*[dD]ate$/' }}
 
     <br/><br/>
 
diff --git a/plugins/WebsiteMeasurable/MeasurableSettings.php b/plugins/WebsiteMeasurable/MeasurableSettings.php
index 7af270b0f9..95e4187f73 100644
--- a/plugins/WebsiteMeasurable/MeasurableSettings.php
+++ b/plugins/WebsiteMeasurable/MeasurableSettings.php
@@ -183,7 +183,7 @@ class MeasurableSettings extends \Piwik\Settings\Measurable\MeasurableSettings
         $self = $this;
         return $this->makeProperty('excluded_parameters', $default = array(), FieldConfig::TYPE_ARRAY, function (FieldConfig $field) use ($self) {
             $field->title = Piwik::translate('SitesManager_ExcludedParameters');
-            $field->inlineHelp = Piwik::translate('SitesManager_ListOfQueryParametersToExclude')
+            $field->inlineHelp = Piwik::translate('SitesManager_ListOfQueryParametersToExclude', "/^sess.*|.*[dD]ate$/")
                 . '<br /><br />'
                 . Piwik::translate('SitesManager_PiwikWillAutomaticallyExcludeCommonSessionParameters', array('phpsessid, sessionid, ...'));
             $field->uiControl = FieldConfig::UI_CONTROL_TEXTAREA;
diff --git a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getAvailableMeasurableTypes.xml b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getAvailableMeasurableTypes.xml
index 4015aad321..3e5457c1ff 100644
--- a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getAvailableMeasurableTypes.xml
+++ b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getAvailableMeasurableTypes.xml
@@ -101,7 +101,7 @@
 						</uiControlAttributes>
 						<availableValues />
 						<description />
-						<inlineHelp>Enter the list of URL Query Parameters, one per line, to exclude from the Page URLs reports.&lt;br /&gt;&lt;br /&gt;Piwik will automatically exclude the common session parameters (phpsessid, sessionid, ...).</inlineHelp>
+						<inlineHelp>Enter the list of URL Query Parameters, one per line, to exclude from the Page URLs reports. Regular expressions such as /^sess.*|.*[dD]ate$/ are suported.&lt;br /&gt;&lt;br /&gt;Piwik will automatically exclude the common session parameters (phpsessid, sessionid, ...).</inlineHelp>
 						<introduction />
 						<condition />
 					</row>
-- 
GitLab