问题
Is there any way to get format settings (country from "Formats" tab on "Region and Language" popup in Windows) in JavaScript so I can pass it to server in cookie? (big target - display dates in correct format on MVC 4 server-side)
In IE9 I can use navigator.UserLanguage (also correct language is passed in Accept-Language http header).
But in Chrome and FF navigator.UserLanguage is undefined, navigator.language and Accept-Language returns browser's interface language.
回答1:
It is not possible for JS or anything else to access this setting, however there is the HTTP_ACCEPT_LANGUAGE language property which can be accessed on the server. For example with PHP you can do:
echo $_SERVER['HTTP_ACCEPT_LANGUAGE'];
which will echo something like en-US
. In most cases this will probably be the users prefered language, so why not use it?
来源:https://stackoverflow.com/questions/14281860/how-to-get-clients-system-region-and-language-settings-on-server