Your code looks good. May only guess is maybe trying to move your initialization part from app.component constructor to app.component ngAfterViewInit for example ? A wild guess is that maybe this.storage isn't yet initialized when you try to access it in your app.component contructor and therefore the default language couldn't be set?
If I doesn't miss it I've to feeling you are not telling ngx-translate which language should be use. You set a default language but doesn't set the one to use. I would add this.translateService.use(...);
-
Also it's possible to guess the language without the storage, so I would do something like
ngAfterViewInit() { let userLang = navigator.language.split('-')[0]; userLang = /(hi)/gi.test(userLang) ? userLang : 'en'; this.translateService.setDefaultLang('en'); this.translateService.use(userLang); this.storage.get('AppLangcode') .then((AppLangcode) => { if(AppLangcode==null){ this.translateService.use(userLang); }else{ this.translateService.use(AppLangcode); } }); }
Not sure it will work but maybe i will give you some ideas?