Closed web-dave closed 6 years ago
OK here is a example how it works for me:
en.json
{
"icu": "{count, plural, =0{No} one{A} other{#}} {count, plural, one{word} other{words}}"
}
Template
<div [translate]="'icu'" [translateParams]="{count: 0}" ></div>
<div [translate]="'icu'" [translateParams]="{count: 1}" ></div>
<div [translate]="'icu'" [translateParams]="{count: 2}" ></div>
Output: No words A word 2 words
@web-dave I'm glad you've figured it out. The thing is: MessageFormat provides the syntax for your strings and ngx-translate provides the ways of including them in your app. None of it is implemented in this compiler, it's just the "glue". I've still added an example in the hope it will help others. Thanks for the input.
Can I please get an example an the translations if the count number is dynamic? Meaning that the count number is coming from a variable within the component.
<div>{{ 'words' | translate:{count: numWords} }}</div>
Po file msgid "words" msgstr "{count, plural, =0{No} one{A} other{#}} {count, plural, one{Word} other{Words}}"
Hi, Great work dude, I'm fighting with the template, can you provide some examples. I tried to get the point from your tests. but with no luck. short help would be nice.