简体   繁体   中英

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM