added i18n support for ngPluralize

transparently localize ngPluralize directives by translating the value
of the "when"-attribute before ngPluralize compiles it
This commit is contained in:
Roman Anasal 2014-09-09 13:02:21 +02:00
parent 1b8da25224
commit 2e148b29a7

View File

@ -128,6 +128,18 @@ angular.module('myApp.i18n', ['izhukov.utils'])
return _; 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(_) { .directive('myI18n', ['_', function(_) {
return { return {
restrict: 'EA', restrict: 'EA',