Angular npm run build - Locale data for 'fr-FR' cannot be found

1.2k Views Asked by At

In my angular.json on adding fr-Fr locale, I see a message Locale data for 'fr-FR' cannot be found. Using locale data for 'fr' on running command npm run build.

However I see the proper structure in my dist folder with fr-FR generated. Is this a warning that can be ignored or something wrong with my configuration.

"i18n": {
        "sourceLocale": "en",
        "locales": {
          "fr-BE": "src/locale/messages.fr-BE.xlf",
          "fr-CA": "src/locale/messages.fr-CA.xlf",
          "fr-FR": "src/locale/messages.fr-FR.xlf",                      
          "fr-LU": "src/locale/messages.fr-LU.xlf"          
        }
      },

PS: is see the same message for other valid locales like zh-HK and others.

1

There are 1 best solutions below

1
On

You must provide the locale in app.module

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 {}