Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get a visitors default currency symbol with javascript?

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)...

like image 907
ShoeMaker Avatar asked Jun 08 '13 19:06

ShoeMaker


1 Answers

As far as I know, There are no libraries or ECMA script to help with this.

I would go about it as:

  1. 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

  2. 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.

like image 86
Joybroto Avatar answered Oct 14 '22 23:10

Joybroto