Skip to content

Commit a0507d8

Browse files
committed
Improve solution of issue siddii#180
1 parent 1b65b94 commit a0507d8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/js/i18nService.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@ app.factory('I18nService', function() {
55
var I18nService = function() {};
66

77
I18nService.prototype.language = 'en';
8+
I18nService.prototype.fallback = 'en';
89
I18nService.prototype.timeHumanizer = {};
910

10-
I18nService.prototype.init = function init(lang){
11+
I18nService.prototype.init = function init(lang, fallback) {
12+
var supported_languages = humanizeDuration.getSupportedLanguages();
13+
14+
this.fallback = (fallback !== undefined) ? fallback : 'en';
15+
if (supported_languages.indexOf(fallback) === -1) {
16+
this.fallback = 'en';
17+
}
18+
1119
this.language = lang;
20+
if (supported_languages.indexOf(lang) === -1) {
21+
this.language = this.fallback;
22+
}
23+
1224
//moment init
1325
moment.locale(this.language); //@TODO maybe to remove, it should be handle by the user's application itself, and not inside the directive
1426

0 commit comments

Comments
 (0)