I am wondering if there is anyway that I can use javascript or jquery to pull information about the default currency symbol for a user. I know that the information is stored in the registry in windows, but I'm not sure about Mac or Linux machines and I'm not sure how I access that information. I'm thinking about using this feature to write a game that detects the system's stored value for currency and displays that symbol to the player for purchases and sales. It is something that will be played internationally (I hope) so it will have to be able to use any currency symbol (eg $ or ¢ or £ or ₤ or € etc)...
-
2In one word, no. But you could geolocate their IP and decide based on that. – Jon Jun 08 '13 at 19:39
-
1Per @Jon's comment: here's an example of jQuery getting the location of you: http://jsfiddle.net/7uyqs/61/ -- Credit of: http://stackoverflow.com/questions/3489460/how-to-get-visitors-location-i-e-country-using-javascript-geolocation – tymeJV Jun 08 '13 at 19:47
-
That is a shame that there is no way to pull the symbol that is stored in `HKEY_Current_User\Control Panel\International\sCurrency` I expect there to be thousands of visitors and uses per day, and really don't want to geolocate all of the visitors (not to mention there is the issue of privacy concerns). – ShoeMaker Jun 09 '13 at 00:09
-
http://norbertlindenberg.com/ecmascript/intl.html can do a lot but not get default currency – Esailija Jun 09 '13 at 02:27
2 Answers
As far as I know, There are no libraries or ECMA script to help with this.
I would go about it as:
Get the locale of the visitor and implement custom logic to show currency based on the given locale. You can try implementing the logic with help of Accept-Language header. Though, there are best practices when using Accept-Language header.
http://www.w3.org/International/questions/qa-accept-lang-locales
If targeting Modern browser, One can also use geolocation to determine the location and have a custom logic to show currency based on the location. Though, users can deny permission to get the geo location.

- 74
- 2
I used JQuery Globalize plug-in - https://github.com/jquery/globalize#currency , but I had the server tell the client what locale to use. I didn't use any client side code to work out the culture

- 1,431
- 2
- 21
- 27