I'm using navigator.languages to detect the browser's language & country code in the form of en-US.
If I set my browser language to English then I get en-US but if I set it to Japanese it only returns ja, without the country code JP. Obviously Japanese is only spoken in Japan in the whole world so they must have omitted it. The same goes for Korean as I get ko instead of ko_KR.
But I need both information because the Facebook SDK script I'm loading requires it in the format of ll_cc as below:
https://connect.facebook.net/en_US/sdk.js
https://connect.facebook.net/ja_JP/sdk.js
According to the Facebook Documentation, Putting ja_JP in the script address is the only way to achieve the change in display language.
I would like to change the display language based on users' browser language settings. (e.g., Japanese, Korean etc)
So how should I go about getting the country code JP from browser?
I was thinking about creating a table to match the language to country code in the case of one-to-one, but I was curious to see if there is better way to approach this.
Thanks for your help in advance.