sprintf.js icon indicating copy to clipboard operation
sprintf.js copied to clipboard

Format for chosen locale

Open rekire opened this issue 7 years ago • 0 comments

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.

rekire avatar Oct 29 '18 05:10 rekire