Reputation: 833
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)...
Upvotes: 7
Views: 5063
Reputation: 1461
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
Upvotes: 0
Reputation: 74
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.
Upvotes: 2