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 29 forks source link

Can't use translate/[translate] directive #28

Closed johnfrades closed 6 years ago

johnfrades commented 6 years ago

Hi, i just want to ask, i'm trying to use translate/[translate] directive but it seems it doesn't work on your library Here's the example:

Not working: <span translate="AREAS" [translateParams]="{ count: 3 }">areas</span> <span [translate]="'AREAS'" [translateParams]="{ count: 3 }">areas</span> The error says "Count is undefined"

Working: <span translate [translateParams]="{ count: 3 }">AREAS</span>

Just want to know on how to make it work with the 2 Not Working examples.

lephyrus commented 6 years ago

That's not enough information. Can you do a minimal reproduction on StackBlitz please?

lephyrus commented 6 years ago

@johnfrades Please re-open if still an issue and you have the reproduction.

artuska commented 5 years ago

@lephyrus @johnfrades I have the same problem:

<span translate="wizard.step" [translateParams]="{current: 1, total: 3}"></span>

throws me an error:

ERROR TypeError: Cannot read property 'current' of undefined

en.json:

"wizard": {
    "step": "Step {current} of {total}"
}

Angular 5+ Translate 9.1.1

artuska commented 5 years ago

Added TranslateMessageFormatDebugCompiler to see debug in console and it shows:

[TranslateMessageFormatCompiler] INTERPOLATE Step {current} of {total} undefined

So, this undefined is an actual [translateParams]="{current: 1, total: 3}" params but they are missing.

artuska commented 5 years ago

This does not work even in latest versions of translate plugins.

Angular — 7.2.5 Translate — 11.0.1 Translate Messageformat Compiler — 4.4.0