Skip to content

Commit 3e96e98

Browse files
committed
Make sure newly loaded strings are always used.
1 parent bde1bf0 commit 3e96e98

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/catalog.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, $h
99
}
1010
};
1111

12+
function broadcastUpdated() {
13+
$rootScope.$broadcast('gettextLanguageChanged');
14+
}
15+
1216
catalog = {
1317
debug: false,
1418
strings: {},
@@ -18,7 +22,7 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, $h
1822

1923
setCurrentLanguage: function (lang) {
2024
this.currentLanguage = lang;
21-
$rootScope.$broadcast('gettextLanguageChanged');
25+
broadcastUpdated();
2226
},
2327

2428
setStrings: function (language, strings) {
@@ -34,6 +38,8 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, $h
3438
this.strings[language][key] = val;
3539
}
3640
}
41+
42+
broadcastUpdated();
3743
},
3844

3945
getStringForm: function (string, n) {
@@ -62,7 +68,6 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, $h
6268
for (var lang in data) {
6369
catalog.setStrings(lang, data[lang]);
6470
}
65-
$rootScope.$broadcast('gettextLanguageChanged');
6671
});
6772
}
6873
};

0 commit comments

Comments
 (0)