Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Locales in Angular 5

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"?

like image 250
Karma Avatar asked Nov 14 '17 12:11

Karma


1 Answers

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);
like image 66
Iteration Avatar answered Sep 30 '22 10:09

Iteration