formatjs / handlebars-intl

Handlebars helpers for internationalization.
http://formatjs.io/handlebars/
Other
265 stars 28 forks source link

Support for padding currency values #75

Closed buildjosh closed 8 years ago

buildjosh commented 8 years ago

Currently if you use the currency helper on a value such as 123.00 it will format it as $123 and 123.30 will be formatted as $123.3. However when displaying currency you almost always want two decimal places. Is there a way to do this?

caridy commented 8 years ago

check https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat, and look for custom formatters, which allow you to define the exact options to be passed into that constructor under the hood when formatting messages like: something {value, number, myOwnConfig}.

As for the assumption of all currency values should have 2 decimal places, that's not accurate, that really depends on the locale, and the currency denomination of each region, you should let the engine to decide that for you depending on the locale.