From 2e148b29a7ef3878238958ee9b7cc57f69540b91 Mon Sep 17 00:00:00 2001 From: Roman Anasal Date: Tue, 9 Sep 2014 13:02:21 +0200 Subject: [PATCH] added i18n support for ngPluralize transparently localize ngPluralize directives by translating the value of the "when"-attribute before ngPluralize compiles it --- app/js/i18n.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/js/i18n.js b/app/js/i18n.js index e5fe0ee1..8ea22717 100644 --- a/app/js/i18n.js +++ b/app/js/i18n.js @@ -128,6 +128,18 @@ angular.module('myApp.i18n', ['izhukov.utils']) return _; }]) + .directive('ngPluralize', ['_', function(_) { + return { + restrict: 'EA', + priority: 1, // execute before built-in ngPluralize + compile: function(element) { + var msgid = element.attr('when'); + var msgstr = _(msgid); + element.attr('when', msgstr); + } + } + }]) + .directive('myI18n', ['_', function(_) { return { restrict: 'EA',