Locales in Angular 5
Asked Answered
L

2

10

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

Lien answered 14/11, 2017 at 12:20 Comment(1)
fyi it's navigator.language, a property not a functionPreoccupied
E
1

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);
Euraeurasia answered 24/1, 2018 at 20:26 Comment(0)
J
0

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\
Jolin answered 1/9, 2021 at 2:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.