Skip to content
Extraits de code Groupes Projets
Valider ade74a4d rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Add new angularjs translation directive to aid in complex translations where...

Add new angularjs translation directive to aid in complex translations where HTML must be embedded in the translated string. Directive allows doing this safely and easily.
parent 17499228
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -131,6 +131,7 @@ class CoreHome extends \Piwik\Plugin
$jsFiles[] = "plugins/CoreHome/angularjs/common/directives/onenter.js";
$jsFiles[] = "plugins/CoreHome/angularjs/common/directives/focusif.js";
$jsFiles[] = "plugins/CoreHome/angularjs/common/directives/dialog.js";
$jsFiles[] = "plugins/CoreHome/angularjs/common/directives/translate.js";
$jsFiles[] = "plugins/CoreHome/angularjs/piwikApp.js";
$jsFiles[] = "plugins/CoreHome/angularjs/anchorLinkFix.js";
......
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* Directive for easy & safe complex internationalization. This directive allows
* users to embed the sprintf arguments used in internationalization inside an HTML
* element. Since the HTML will eventually be sanitized by AngularJS, HTML can be used
* within the sprintf args. Using the filter, this is not possible w/o manually sanitizing
* and creating trusted HTML, which is not as safe.
*
* Usage:
* <span piwik-translate="Plugin_TranslationToken">
* first arg:<strong>second arg</strong>:{{ unsafeDataThatWillBeSanitized }}
* </span>
*/
angular.module('piwikApp.directive').directive('piwikTranslate', function() {
return {
restrict: 'A',
scope: {
piwikTranslate: '@'
},
compile: function(element, attrs) {
var parts = element.html().split(':'),
translated = _pk_translate(attrs.piwikTranslate, parts);
element.html(translated);
}
};
});
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