Admit locales (es-ES, en-GB, etc.) to format the numbers
See original GitHub issueCurrent behavior
Currently is necessary to describe how to format numbers and currencies by hand (except some languages), which makes it more involved on apps with a lot of languages because it’s necessary to provide the configuration for each of them.
Expected behavior
There is a native Intl.NumberFormat
object (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat) that supports the locales.
Those locales work quite well, although they aren’t as customizable as autoNumeric
, and it’s not possible to use cryptocurrencies or custom currencies. The biggest advantage is that they are just ready to use on all browsers without coding anything.
It could work like this:
new AutoNumeric(domElement, { locale: 'ja-JP' });
The locale configuration could later be overridden by any of the autoNumeric
options.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top GitHub Comments
@AlexandreBonneau I submitted polished versions covering edge cases of above functions to npm and github. Please see intl-data source code.
You can use it or copy/paste it into your source code as you wish. I appreciate if you include my credits also.
@AlexandreBonneau please see above proposed solution. Also it could be a good idea to memoize values.