Rajesh
Rajesh

Reputation: 2502

Angular i18n not supporting all locales in angular.json

My angular application I want to support languages french(Canada), french(France) and US english. This is my angular.json file i18n code.

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

Upon Building application (npm run build) I see a message Locale data for 'fr-FR' cannot be found. Using locale data for 'fr'.

  1. Does this mean fr-FR is not allowed in angular.json, as it is not in ISO-639 list.
  2. Should I use "fr": "src/locale/messages.fr.xlf" instead of fr-FR. Then should I match if the user in France (fr-FR locale) load code from fr in dist folder.
  3. If '2' is wrong ignore the warning and as build producing fr-Fr specific application in dist folder use that.
  4. If '2' is correct does that apply for all locales say use en for 'en-GB','en-CA'...

I know there is something like registerLocaleData for displaying of dates and currency.

registerLocaleData(localeFr); 

providers: [
    { provide: LOCALE_ID, useValue: 'fr-FR'},
  ]

I went over documentation few times https://angular.io/guide/i18n-overview. I know I am missing something.

Upvotes: 3

Views: 1183

Answers (0)

Related Questions