0

When a user lands on my site, I'd like to get the language code corresponding to the language they're using. (e.g, "en-US" for US English, "fr-CA" for French Canadian.) I have some culture/language dependant features. (Among other things, there's a french translation of the site in the works.) I have a central place to store that language code, and what I have works in Chrome and Firefox using navigator.language, as well as Internet Explorer using navigator.browserLanguage. What I need is a way to get this information from a user in Microsoft Edge.

I'm using Javascript, AngularJS, and Kendo if one of those has a useful tool. I would mildly prefer a pure Javascript answer, and would strongly prefer to do this entirely in the frontend.

Note: It's possible that navigator.language actually does this in Edge. That returns "en-US" for me and I am in the US, but I'm using a testing environment that should be set up to look like it's from the UK. Confirmation that navigator.language will get the user language and that my environment is just leaky counts as an answer, especially if it includes exactly where Edge gets that information so I can fix my environment and test it.

Skyler Crossman
  • 111
  • 2
  • 6
  • check out this [question](http://stackoverflow.com/questions/1043339/javascript-for-detecting-browser-language-preference). I think you can find a solution in one of the answers. – tfidelis Feb 02 '17 at 17:10
  • @tfidelis Thank you, but I have seen that question. The accepted answer is seven years old and out of date. navigator.language(s) does work for chrome and firefox, as one of the other answers suggests, but that answer doesn't provide any solution for Edge. In fact, most of those answers were posed prior to Edge being released. The java or backend based solutions look like they'd work, but as I stated in my question I'd much rather have a frontend javascript solution. – Skyler Crossman Feb 02 '17 at 18:29

0 Answers0