Angular i18n - Error: No plural message found for value "0"

1k Views Asked by At

I am following the development guide of Angular i18n: https://angular.io/guide/i18n

I have defined a plural literal like this:

<span i18n>Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}}</span>

I have defined a variable in MyComponent.ts like this:

minutes = 0;

I am running my application like this:

ng serve --port 4300 --configuration=fr

I have defined the messages.fr.xlf like this:

<trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
    <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
    <context-group purpose="location">
      <context context-type="sourcefile">app/tenants/tenant1/tenant1.module.ts</context>
      <context context-type="linenumber">4</context>
    </context-group>
    <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
  </trans-unit>

But when I load the page I have the following error:

 Error: No plural message found for value "0"

Please, what am I doing wrong?

1

There are 1 best solutions below

0
On

Solution:

I was not importing correctly CommonModule which contains NgPlural & NgSwitch;

import { CommonModule } from '@angular/common';