Reputation: 2226
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"?
Upvotes: 10
Views: 5077
Reputation: 4530
To see a list of available locales, you can install a new angular app, and add localisation support:
ng add @angular/localize
Then look in your app's folder for a listing:
\node_modules\@angular\common\locales\
Upvotes: 0
Reputation: 693
This is so problematic also for me:
Please find here an import of ALL the Angular 5 locales : http://iteration.info/Sharing/AllAngular5Locales.rtf
I hope in Angular 6 will do :
import locales($var);
Upvotes: 1