Defining your preferred language in IE11 does not work

For the project, I have to provide two versions of the web page: one English and one French. Since I'm in the UK, the browser (IE11) is naturally installed in the local language (en-GB). To check french, I went to

Internet-Options->Languages->Set Language Preference->Add a Language (French-France) (or select the language if already there) 

and make sure that French is at the top. I have a JSF page where the language is detected using Java, and it works fine, all the text is taken from the properties file of France, not the properties file in English, which automatically switches when changing the language between English and French. However, for one webpage I need to determine the current language in JavaScript, and whatever I try, it remains en-GB.

I tried this code:

 var language = navigator.languages && navigator.languages[0] || navigator.language || navigator.userLanguage; 

It returns 'en-GB'. I tried it myself in the F12 debugger:

 navigator.languages returns: undefined navigator.userLanguage: en-GB navigator.language: undefined navigator.browserLanguage: en-US 

This is IE11 version 11.0.9600.17031

I am also in Windows 8, and on the Windows main screen (after accidentally pressing the Windows key ...) everything is also displayed in French (news, weather, etc.), so the French language is selected, but how to determine this in JavaScript?

+5
source share
1 answer

Internet Explorer adheres to the language settings set in Windows, but apparently there is no way to access this information from JavaScript. The best you can do is detect the language on the server and return the information to your script.

If you want to manually view the Accept-Language heading, press [F12] to enable the developer tools, then [Ctrl] + [4] for a tab on the network and make a request (you can just press [F5]). On the right you will see a panel for headings. In the "Request Headers" section, you will see "Accept-Language", which should be the value you want. I repeat, although, as far as I know, there is no way to get the same information exclusively from JavaScript.

+2
source

Source: https://habr.com/ru/post/1270674/


All Articles