Angular i18n - Ошибка: не найдено множественное сообщение для значения "0" - PullRequest
0 голосов
/ 09 октября 2018

Я следую руководству по разработке Angular i18n: https://angular.io/guide/i18n

Я определил множественное число, подобное этому:

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

Я определил переменную в MyComponent.ts, напримерthis:

minutes = 0;

Я запускаю свое приложение так:

ng serve --port 4300 --configuration=fr

Я определил messages.fr.xlf так:

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

Нопри загрузке страницы появляется следующая ошибка:

 Error: No plural message found for value "0"

Пожалуйста, что я делаю не так?

1 Ответ

0 голосов
/ 10 октября 2018

Решение:

Я неправильно импортировал CommonModule , который содержит NgPlural & NgSwitch ;

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