File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments