currency.js
currency.js copied to clipboard
Use Intl.NumberFormat for formatting values
Formatting is already pretty versatile, but we could also potentially leverage Intl.NumberFormat
to get a lot of different formats for "free". The one downside is that it's possible that parsing and formatting are out of sync if the options aren't the same.
Just a heads up; Intl
isn't available in react-native's JavaScriptCore in Android (hence why I'm looking at this library).
Exactly! I'm using Currency.JS to replace missing react-native's Intl API.
I got Intl working react-native changing the jscFlavor, but it increased the build size in 6MB!
:-1: for this — while it is super convenient and provides a much broader support in terms in i18n, in a recent version of chrome they changed how they formatted numbers without a currency specified (we're using Dinero.js) leading to local currencies across the world being formatted as "USD$9.99". There is an argument for just keeping it simple and explicit.