Missing locale data for locale "XXX" with angular

I am currently defining "LOCALE_ID" on "en-US" as follows:

@NgModule({
    providers: [{ provide: LOCALE_ID, useValue: "en-US" }, ...],
    imports: [...],
    bootstrap: [...]
})

and it works very well. However, to check how the dates look in French, I replaced "en-US" with "fr-FR" and then got an error:

The locale data for the fr-FR locale is missing.

I did some research, and I did not find anything related to this. Are language standards for French included in the package by default? Is this a different package? Do I need to create them myself?

+18
source share
3 answers

In file app.module.ts

...
import { NgModule, LOCALE_ID } from '@angular/core';
import { registerLocaleData } from '@angular/common';
import localeFr from '@angular/common/locales/fr';
registerLocaleData(localeFr);


@NgModule({
  imports: [...],
  declarations: [...],
  bootstrap: [...],
  providers: [
    { provide: LOCALE_ID, useValue: 'fr-FR'},
  ]
})
export class AppModule {}

(source: https://next.angular.io/guide/i18n )

(*.component.html)

DATE in FRENCH: {{ dateEvent | date: 'longDate'}}

:

DATE in FRENCH: 25 mars 2018

(: https://angular.io/api/common/DatePipe)

+24

@Alan, : import { registerLocaleData } from '@angular/common';

:

import { registerLocaleData } from '@angular/common';
import localeFr from '@angular/common/locales/fr';
registerLocaleData(localeFr);

@NgModule({
  imports: [...],
  declarations: [...],
  bootstrap: [...],
  providers: [
    { provide: LOCALE_ID, useValue: 'fr-FR'},
  ]
})
export class AppModule {}
+2

please take a look at https://github.com/angular/angular-cli/issues/6683

it may be your case

0
source

Source: https://habr.com/ru/post/1686382/


All Articles