Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@piwik.org>2016-12-05 20:37:19 +0300
committerGitHub <noreply@github.com>2016-12-05 20:37:19 +0300
commitcbec998d78318539a206befc88ff9e696541da9a (patch)
tree28f89ca238ed58bfe07c914f541273e0d6c19719
parent1d0dcc553611b551bd8a621a0790f91b897968dd (diff)
always unescape escaped % symbols in translations (#10917)
* always unescape escaped % symbols in translations * adds new tests to proove %-symbols are escaped in english translations * submodule update
-rw-r--r--core/Translation/Translator.php2
-rw-r--r--lang/en.json2
-rw-r--r--plugins/Actions/lang/en.json2
m---------plugins/CustomAlerts0
-rwxr-xr-xplugins/LanguagesManager/Test/Integration/LanguagesManagerTest.php26
5 files changed, 29 insertions, 3 deletions
diff --git a/core/Translation/Translator.php b/core/Translation/Translator.php
index af2ae597f2..98b3759f3b 100644
--- a/core/Translation/Translator.php
+++ b/core/Translation/Translator.php
@@ -84,7 +84,7 @@ class Translator
}
if (count($args) == 0) {
- return $translationId;
+ return str_replace('%%', '%', $translationId);
}
return vsprintf($translationId, $args);
}
diff --git a/lang/en.json b/lang/en.json
index ab7e7dcc9c..ce3caaa2fe 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -70,7 +70,7 @@
"ColumnPageBounceRateDocumentation": "The percentage of visits that started on this page and left the website straight away.",
"ColumnPageviews": "Pageviews",
"ColumnPageviewsDocumentation": "The number of times this page was visited.",
- "ColumnPercentageVisits": "% Visits",
+ "ColumnPercentageVisits": "%% Visits",
"ColumnRevenue": "Revenue",
"ColumnSumVisitLength": "Total time spent by visitors (in seconds)",
"ColumnTotalPageviews": "Total Pageviews",
diff --git a/plugins/Actions/lang/en.json b/plugins/Actions/lang/en.json
index c31dc264ec..27c9b2f72f 100644
--- a/plugins/Actions/lang/en.json
+++ b/plugins/Actions/lang/en.json
@@ -18,7 +18,7 @@
"ColumnSearchCategory": "Search Category",
"ColumnSearches": "Searches",
"ColumnSearchesDocumentation": "The number of visits that searched for this keyword on your website's search engine.",
- "ColumnSearchExits": "% Search Exits",
+ "ColumnSearchExits": "%% Search Exits",
"ColumnSearchExitsDocumentation": "The percentage of visits that left the website after searching for this Keyword on your Site Search engine.",
"ColumnSearchResultsCount": "Search Results Count",
"ColumnSiteSearchKeywords": "Unique Keywords",
diff --git a/plugins/CustomAlerts b/plugins/CustomAlerts
-Subproject 49ae454fd7eae39e07300c83e0dff40dda2e427
+Subproject 8c861c9084a25dc36e1176496598a175a1619ee
diff --git a/plugins/LanguagesManager/Test/Integration/LanguagesManagerTest.php b/plugins/LanguagesManager/Test/Integration/LanguagesManagerTest.php
index 0ff66919ce..59124a79cd 100755
--- a/plugins/LanguagesManager/Test/Integration/LanguagesManagerTest.php
+++ b/plugins/LanguagesManager/Test/Integration/LanguagesManagerTest.php
@@ -156,6 +156,32 @@ class LanguagesManagerTest extends \PHPUnit_Framework_TestCase
}
/**
+ * check all english translations do not contain unescaped % symbols
+ *
+ * @group Plugins
+ * @group numbered2
+ */
+ function testTranslationsUseEscapedPercentSigns()
+ {
+ Cache::flushAll();
+ $translator = StaticContainer::get('Piwik\Translation\Translator');
+ $translator->reset();
+ Translate::loadAllTranslations();
+ $translations = $translator->getAllTranslations();
+ foreach ($translations AS $plugin => $pluginTranslations) {
+ if ($plugin == 'Intl') {
+ continue; // skip generated stuff
+ }
+ foreach ($pluginTranslations as $key => $pluginTranslation) {
+ $pluginTranslation = preg_replace('/(%(?:[1-9]\$)?[a-z])/', '', $pluginTranslation); // remove placeholders
+ $pluginTranslation = str_replace('%%', '', $pluginTranslation); // remove already escaped symbols
+ $this->assertEquals(0, substr_count($pluginTranslation, '%'),
+ sprintf('%s.%s must use escaped %% symbols', $plugin, $key));
+ }
+ }
+ }
+
+ /**
* test English short name for language
*
* @group Plugins