I want to set some default settings for my app. In doing so, I want to catch the systems language. I then export a function in the app.module.ts but it gives me a Cannot read property 'lang' of undefined
I am wondering, could it be that navigator is not available at this time when the code runs? Or is some async messing things up??
Here’s my code in app.module.ts so far:
export function provideSettings(storage: Storage) {
// detect the system language of fall back to the default language for translation strings.
let userLang = navigator.language.split("-")[0]; //use navigator lang if available
userLang = /(nl|en)/gi.test(userLang) ? userLang : 'nl';
return new Settings(storage, {
lang: userLang,
remindTime: "19:00",
remindAgenda: false,
remindNotify: false,
});
}
I don’t think you’re showing us where the error is spawning from, because I don’t see an attempt to access a property named ‘lang’ in the code you posted.