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 mix pluralization and variable replacement in JSON #15

Closed krysalead closed 6 years ago

krysalead commented 6 years ago

Hi,

Thanks for your implementation. I got an issue today mixing pluralization syntax and replacement syntax in json file. I got a parsing issue. If I remove the ngx-translate-messageformat-compiler from the module config I can use the variable replacement but no more the pluralization.

JSON

{ "home": { "title": "Hello {{userName}}", "label": { "weeks": "{nbWeek, plural, one{week} other{# weeks}}" } } }

Ngmodule

TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: HttpLoaderFactory, deps: [HttpClient] }, compiler: { provide: TranslateCompiler, useClass: TranslateMessageFormatCompiler } })

Thanks & regards

Olivier

lephyrus commented 6 years ago

You need to use messageformat's syntax, which does not use double curly braces. Please read the REAMDE.

krysalead commented 6 years ago

Sorry, I missed it.