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

Fix error when using a formatter and no customFormatters were passed #96

Closed Maks-s closed 2 years ago

Maks-s commented 2 years ago

There's an error when the user use a formatter (like number), after no customFormatters were passed to messageformat

The error : TypeError: can't access property "number", this.options.customFormatters is undefined in https://example.com/vendor.js (line XXX)

This PR fix the issue (see test)

I wonder if it should be fixed in messageformat's repo too

lephyrus commented 2 years ago

Thanks for the PR, @Maks-s! It does seem like an upstream bug that you have to pass {} as customFormatters for the number formatter to work. I've never used any of the included formatters, so I didn't notice. I should probably add tests for the other included formatters at some point.

Could you update the README to indicate the new default value for formatters? Then I'll merge the PR.

egalley commented 2 years ago

Thank you, for the solution.