Skip to content

Commit c6bbb0f

Browse files
committed
Fix IE8 translating strings with tags.
Related to #51
1 parent fcf3483 commit c6bbb0f

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

dist/angular-gettext.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,18 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "$http",
5353
if (!this.strings[language]) {
5454
this.strings[language] = {};
5555
}
56-
56+
// IE8 returns UPPER CASE tags, even though the source is lower
57+
// case.
58+
// This can causes the (key) string in the DOM to have a different
59+
// case to the string in the `po` files.
60+
var test = '<span>test</span>';
61+
var isUpperCaseTags = (angular.element('<span>' + test + '</span>').html() !== test);
5762
for (var key in strings) {
5863
var val = strings[key];
64+
if (isUpperCaseTags) {
65+
// Use the DOM engine to uppercase any tags in the key.
66+
key = angular.element('<span>' + key + '</span>').html();
67+
}
5968
if (typeof val === 'string') {
6069
this.strings[language][key] = [val];
6170
} else {

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/catalog.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,18 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, $h
4141
if (!this.strings[language]) {
4242
this.strings[language] = {};
4343
}
44-
44+
// IE8 returns UPPER CASE tags, even though the source is lower
45+
// case.
46+
// This can causes the (key) string in the DOM to have a different
47+
// case to the string in the `po` files.
48+
var test = '<span>test</span>';
49+
var isUpperCaseTags = (angular.element('<span>' + test + '</span>').html() !== test);
4550
for (var key in strings) {
4651
var val = strings[key];
52+
if (isUpperCaseTags) {
53+
// Use the DOM engine to uppercase any tags in the key.
54+
key = angular.element('<span>' + key + '</span>').html();
55+
}
4756
if (typeof val === 'string') {
4857
this.strings[language][key] = [val];
4958
} else {

0 commit comments

Comments
 (0)