lephyrus / ngx-translate-messageformat-compiler

Advanced pluralization (and more) for ngx-translate, using standard ICU syntax which is compiled with the help of messageformat.js.
MIT License
93 stars 30 forks source link

Dynamic variable in html template #37

Closed KevinJue closed 6 years ago

KevinJue commented 6 years ago

Hello,

I'm actually trying to use pluralization, it work fine like that:

{{'STORE.STOREFOUND' | translate:"{ count: 2 }"}}
"STOREFOUND": "We found {count, plural, =0{nothing} one{# store} other{# stores}}."

output look like it should be.

But i'm trying to use a dynamic value for the count {{'STORE.STOREFOUND' | translate:"{ count: {{numberOfStores}} }"}}

@lephyrus is it possible, because i found any solution on your readme ?

KevinJue commented 6 years ago

Actually we can just make: {{'STORE.STOREFOUND' | translate:numberOfStores}} and create the object in the ts files like that: numberOfStores = { count: 0 };

lemoinem commented 6 years ago

@KevinJue You could also omit the quotes around your count object: {{'STORE.STOREFOUND' | translate:{ count: numberOfStores } }}

byzg commented 5 years ago

Pay attention for the last space in @lemoinem message https://github.com/angular/angular/issues/9571