sprintf.js
sprintf.js copied to clipboard
Format for chosen locale
I'm wondering why there is no option to specify the locale. After a small research I found out that it is not so easy as expected initial, but it seems to be able.
Number has the prototype toLocaleString() which does that what I would expect. See also MDN for more details. Spoiler: You need to set minimumFractionDigits and maximumFractionDigits as options.
Just for those which are not familiar the correct formatted result of 10000 divided by 3 is in en-US: 3,333.33 while in de_DE: 3.333,33.