Skip to content

Fix IE8 translating strings that contain html tags. #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dist/angular-gettext.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ angular.module('gettext').constant('gettext', function (str) {
angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "$http", "$cacheFactory", "$interpolate", "$rootScope", function (gettextPlurals, $http, $cacheFactory, $interpolate, $rootScope) {
var catalog;

// IE8 returns UPPER CASE tags, even though the source is lower case.
// This can causes the (key) string in the DOM to have a different case to
// the string in the `po` files.
var test = '<span>test</span>';
var isUpperCaseTags = (angular.element('<span>' + test + '</span>').html() !== test);

var prefixDebug = function (string) {
if (catalog.debug && catalog.currentLanguage !== catalog.baseLanguage) {
return catalog.debugPrefix + string;
Expand Down Expand Up @@ -56,6 +62,10 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "$http",

for (var key in strings) {
var val = strings[key];
if (isUpperCaseTags) {
// Use the DOM engine to uppercase any tags in the key.
key = angular.element('<span>' + key + '</span>').html();
}
if (typeof val === 'string') {
this.strings[language][key] = [val];
} else {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-gettext.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/catalog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, $http, $cacheFactory, $interpolate, $rootScope) {
var catalog;

// IE8 returns UPPER CASE tags, even though the source is lower case.
// This can causes the (key) string in the DOM to have a different case to
// the string in the `po` files.
var test = '<span>test</span>';
var isUpperCaseTags = (angular.element('<span>' + test + '</span>').html() !== test);

var prefixDebug = function (string) {
if (catalog.debug && catalog.currentLanguage !== catalog.baseLanguage) {
return catalog.debugPrefix + string;
Expand Down Expand Up @@ -44,6 +50,10 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, $h

for (var key in strings) {
var val = strings[key];
if (isUpperCaseTags) {
// Use the DOM engine to uppercase any tags in the key.
key = angular.element('<span>' + key + '</span>').html();
}
if (typeof val === 'string') {
this.strings[language][key] = [val];
} else {
Expand Down