I am trying to convert a float from one culture to another, and seems nothing i found online was working for me. The problem is:
this means i have to somehow convert from the static culture ("en-US") to whatever is selected ON THE CLIENT, before the data is sent to the server for processing, so all the data from the client is on one culture.
I believed that Globalization jQuery plugin (GitHub) will provide this functionality for formatting numbers (and dates) in given culture out-of-the-box, but it seems it do not.
What i tried:
using the Globalization plugin, setting Globalize.culture
property, and hoping that Globalize.format(Globalize.parseFloat("1.2435677777", 10, "en-US")))
will format the value with the desired decimal separator. However it seems it does not worked for me.
If anyone can point what i did wrong, and give a better working example - will be great.
As the Globalize.format() function always returns a '.' decimal separator, as far as i understood, there is a little hacky solution, but at least it works. The point is at replacing the 'neutral' decimal separator with that for the current culture
Globalize.parseFloat("1.2435677777", 10, "en-US").toString().replace(".", Globalize.cultures[Globalize.cultureSelector].numberFormat["."])