The task is to determine the user language set in the browser that has the highest priority.
We have:

var userLang = navigator.language || navigator.userLanguage; 

In Opera, Chrome determines the language correctly and determines the first one in the list. IE / Edge defines a language that is set to "regional features", i.e. it makes no difference what language priorities were set along the path "Control Panel \ All Control Panel Items \ Language". (OS Windows 10).
The definition is needed in order to properly highlight the current language of the web application when you first visit, then it is done on the basis of cookie data. Is it possible to resolve the issue?

  • The oddities of the donkey and its receiver are already a parable about which browser you don’t need to be. - user207618
  • @Other, do not define a language on the client. Just this week I read an article on this topic. - Qwertiy
  • OK, then how can I change the style of the language change button? - xrk
  • @xrk, change for what? - Qwertiy
  • Completed the answer. - Qwertiy

1 answer 1

correctly highlight the current language of the web application when you first visit

In fact, this should be done by the server based on the Accept-Language http header:

 Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4 

Another question on this topic.

this is further based on cookie data.

Here is the server based on the first request and should form them.

  • Thanks, I dig the server. - xrk