globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 605 forks source link

Reuse pluralGenerator for messageFormatter #817

Closed bingzheyuan closed 6 years ago

bingzheyuan commented 6 years ago

https://github.com/globalizejs/globalize/blob/67b75feb6d597801ec94e571424b49f26711ba0b/src/message.js#L85-L88 Message Formatter seems to generate a plural Generator for every formatter, should we reduce this behaviour? We should have a default one (if we have a globalize instance) or we don't need it at all, not every message needs a plural generator.

rxaviers commented 6 years ago

By using globalize-compiler, this is going to be cached...

A generic way of solving this for the non-compiled case is #470

rxaviers commented 6 years ago

Closing this in favor of https://github.com/globalizejs/globalize/pull/470#issuecomment-405654057