Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing locale data for the locale "de-DE"

I'm using Angular 9

In one of my components, I'm using Currency Formatting as bellow:

import { formatCurrency } from '@angular/common';
formatCurrency(23456, 'de-DE', '$')

Here, if I pass de-DE as culture, I'm getting error as below:

Missing locale data for the locale "de-DE"

But, if I pass the culture as en-DE, it's working fine.

What's the issue here? Please help in this.

like image 209
Unknown Coder Avatar asked Feb 02 '21 12:02

Unknown Coder


1 Answers

By default angular only contains the locale data for English.

You will need to import and register the correct locale if you want it to work.

import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';
import localeDeExtra from '@angular/common/locales/extra/de';

registerLocaleData(localeDe, 'de-DE', localeDeExtra);

then you should be able to use it.

It would make most sense to register the locale inside your app.module.ts

like image 150
kacase Avatar answered Nov 07 '22 20:11

kacase