Skip to content
Extraits de code Groupes Projets
Valider cbec998d rédigé par Stefan Giehl's avatar Stefan Giehl Validation de GitHub
Parcourir les fichiers

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
parent 1d0dcc55
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -84,7 +84,7 @@ class Translator ...@@ -84,7 +84,7 @@ class Translator
} }
if (count($args) == 0) { if (count($args) == 0) {
return $translationId; return str_replace('%%', '%', $translationId);
} }
return vsprintf($translationId, $args); return vsprintf($translationId, $args);
} }
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
"ColumnPageBounceRateDocumentation": "The percentage of visits that started on this page and left the website straight away.", "ColumnPageBounceRateDocumentation": "The percentage of visits that started on this page and left the website straight away.",
"ColumnPageviews": "Pageviews", "ColumnPageviews": "Pageviews",
"ColumnPageviewsDocumentation": "The number of times this page was visited.", "ColumnPageviewsDocumentation": "The number of times this page was visited.",
"ColumnPercentageVisits": "% Visits", "ColumnPercentageVisits": "%% Visits",
"ColumnRevenue": "Revenue", "ColumnRevenue": "Revenue",
"ColumnSumVisitLength": "Total time spent by visitors (in seconds)", "ColumnSumVisitLength": "Total time spent by visitors (in seconds)",
"ColumnTotalPageviews": "Total Pageviews", "ColumnTotalPageviews": "Total Pageviews",
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"ColumnSearchCategory": "Search Category", "ColumnSearchCategory": "Search Category",
"ColumnSearches": "Searches", "ColumnSearches": "Searches",
"ColumnSearchesDocumentation": "The number of visits that searched for this keyword on your website's search engine.", "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.", "ColumnSearchExitsDocumentation": "The percentage of visits that left the website after searching for this Keyword on your Site Search engine.",
"ColumnSearchResultsCount": "Search Results Count", "ColumnSearchResultsCount": "Search Results Count",
"ColumnSiteSearchKeywords": "Unique Keywords", "ColumnSiteSearchKeywords": "Unique Keywords",
......
Subproject commit 49ae454fd7eae39e07300c83e0dff40dda2e4276 Subproject commit 8c861c9084a25dc36e1176496598a175a1619ee9
...@@ -155,6 +155,32 @@ class LanguagesManagerTest extends \PHPUnit_Framework_TestCase ...@@ -155,6 +155,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 * test English short name for language
* *
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter