locbet / jquery-numberformatter

Automatically exported from code.google.com/p/jquery-numberformatter
0 stars 0 forks source link

Request option(s) to specify the locale formatting chars #55

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
There are many locale codes missing in the numberformatter.

In my case I can look-up the client's culture info and can provide the needed 
formatting characters, but there is no option for that in numberformatter.

To solve this issue I modified the formatCodes(locale) function with these 
added lines to accept provided formatting chars though the locale option:

// check if formatting chars is given as locale
var nf = locale.match(/formatchars\|(.+)\|(.+)\|(.+)/);
if (nf != null) {
    return new FormatData(nf[1], nf[2], nf[3]);
}

This makes me able to do this:
var number = $.formatNumber(number, {format:"#,###.00", locale:"formatchars|,| 
|-"});

To do this properly (without my hack) I wish you could implement support for 
giving the formatting chars as options instead of using "locale", eg.:
var number = $.formatNumber(number, {format:"#,###.00", decimal-separator:"," 
grouping-separator:" " negative-sign:"-"});

Original issue reported on code.google.com by jorn.dal...@gmail.com on 12 Oct 2011 at 8:39

GoogleCodeExporter commented 8 years ago
Thanks for the feedback, it's a good idea and not that hard to add in as you 
mention. I'm not currently really adding in new things since I'm in the process 
of doing a rewrite over on github (slowly). But since this is so easy to add I 
might as well do it.

This will be included in the next release (1.2.4), both parse and format will 
have 3 overrides as follows -

overrideGroupSep
overrideDecSep
overrideNegSign

I held off doing one for % sign since it requires more work.

Original comment by apar...@gmail.com on 22 Oct 2013 at 10:24