Skip to content

Commit c84d3bb

Browse files
committed
Merge branch 'fix-ie8-anchor-comment' of https://github.com/maxpeterson/angular-gettext
Conflicts: dist/angular-gettext.min.js
2 parents d0e8613 + 10dcb27 commit c84d3bb

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

dist/angular-gettext.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "$http",
114114
return catalog;
115115
}]);
116116

117-
angular.module('gettext').directive('translate', ["gettextCatalog", "$parse", "$animate", "$compile", function (gettextCatalog, $parse, $animate, $compile) {
117+
angular.module('gettext').directive('translate', ["gettextCatalog", "$parse", "$animate", "$compile", "$window", function (gettextCatalog, $parse, $animate, $compile, $window) {
118118
// Trim polyfill for old browsers (instead of jQuery)
119119
// Based on AngularJS-v1.2.2 (angular.js#620)
120120
var trim = (function () {
@@ -134,6 +134,8 @@ angular.module('gettext').directive('translate', ["gettextCatalog", "$parse", "$
134134
}
135135
}
136136

137+
var msie = parseInt((/msie (\d+)/.exec(angular.lowercase($window.navigator.userAgent)) || [])[1], 10);
138+
137139
return {
138140
restrict: 'AE',
139141
terminal: true,
@@ -146,6 +148,14 @@ angular.module('gettext').directive('translate', ["gettextCatalog", "$parse", "$
146148
var translatePlural = attrs.translatePlural;
147149
var translateContext = attrs.translateContext;
148150

151+
if (msie <= 8) {
152+
// Workaround fix relating to angular adding a comment node to
153+
// anchors. angular/angular.js/#1949 / angular/angular.js/#2013
154+
if (msgid.slice(-13) === '<!--IE fix-->') {
155+
msgid = msgid.slice(0, -13);
156+
}
157+
}
158+
149159
return {
150160
post: function (scope, element, attrs) {
151161
var countFn = $parse(attrs.translateN);

dist/angular-gettext.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/directive.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
angular.module('gettext').directive('translate', function (gettextCatalog, $parse, $animate, $compile) {
1+
angular.module('gettext').directive('translate', function (gettextCatalog, $parse, $animate, $compile, $window) {
22
// Trim polyfill for old browsers (instead of jQuery)
33
// Based on AngularJS-v1.2.2 (angular.js#620)
44
var trim = (function () {
@@ -18,6 +18,8 @@ angular.module('gettext').directive('translate', function (gettextCatalog, $pars
1818
}
1919
}
2020

21+
var msie = parseInt((/msie (\d+)/.exec(angular.lowercase($window.navigator.userAgent)) || [])[1], 10);
22+
2123
return {
2224
restrict: 'AE',
2325
terminal: true,
@@ -30,6 +32,14 @@ angular.module('gettext').directive('translate', function (gettextCatalog, $pars
3032
var translatePlural = attrs.translatePlural;
3133
var translateContext = attrs.translateContext;
3234

35+
if (msie <= 8) {
36+
// Workaround fix relating to angular adding a comment node to
37+
// anchors. angular/angular.js/#1949 / angular/angular.js/#2013
38+
if (msgid.slice(-13) === '<!--IE fix-->') {
39+
msgid = msgid.slice(0, -13);
40+
}
41+
}
42+
3343
return {
3444
post: function (scope, element, attrs) {
3545
var countFn = $parse(attrs.translateN);

0 commit comments

Comments
 (0)