I am new to the concept of locales. From what I could understand, I made an Angular 4 app that would read the locale from the browser using the navigator.language()
API and supply to Angular's pipes. Since all of this changes with v5, I have some questions around migration.
My understanding is that the list here: https://github.com/angular/angular/tree/master/packages/common/locales provides a list of locales that can be supplied to registerLocaleData()
.
Thus, I can import localeEnIn from '@angular/common/locales/en-IN'
and registerLocaleData(localeEnIn)
to activate the locale.
To automatically load the app in the browser's locale, I will have to use the navigator.language()
API to get the locale ID (say "en-GB") and call registerLocaleData(localeEnGb)
where localeEnGb
is imported from the list above. Can this be automated without me having to specify all locales?
There are locales like en
and de
. Should I split the response of navigator.language()
and supply just "en"?