I am trying to determine the browser's language set on Google Chrome, in Settings → Language and input settings, using JavaScript.
I'm trying to do this like so:
var lng=window.navigator.language;
alert(lng);
In Firefox, is working fine, showing the correct language.
I am searching for a way to determine this in Google Chrome, because for the case can-Fr, it shows to me en-US.
var lng = window.navigator.userLanguage || window.navigator.language;
Works in Chrome too, although sometimes it may not reflect the actual browser setting. In this case you might need to retrieve it from the HTTP Headers. Unfortunately the only way to retrieve this via Javascript is by pinging an AJAX request, see: JavaScript for detecting browser language preference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With