acceptedlanguages.js
acceptedlanguages.js copied to clipboard
Internet Explorer doesn't return the Accept-Language information
The results from Internet Explorer are nothing like the actual Accept-Language headers send.
From http://validator.w3.org/i18n-checker/, I get "fr-FR, fr, en-AU, en, si, ru, he" but from the library I get "en-AU", which isn't even the first language I specified.
Thanks for rewiring the issue. Could you share the html that you are including it in? And what version of internet explorer are you using?
The library will give you the accepted
, alternate
and relevant
languages. accepted
is the languages that the user's browser is configured as the preferred languages of the user. alternate
is the languages supported by the web page, as defined in it's link relations. relevant
is the intersection of the two.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script type="text/javascript" src="acceptedlanguages.min.js"></script>
</head>
<body>
<div id="accepted"></div>
<div id="alternate"></div>
<div id="relevant"></div>
<script type="text/javascript">
document.getElementById("accepted").innerHTML = "Accepted: " + acceptedlanguages.accepted.join(", ");
document.getElementById("alternate").innerHTML = "Alternate: " + acceptedlanguages.alternate.join(", ");
document.getElementById("relevant").innerHTML = "Relevant: " + acceptedlanguages.relevant.join(", ");
</script>
</body>
</html>
Output:
Accepted: en-AU
Alternate:
Relevant:
Internet Explorer 11, Windows 10
Languages installed in Windows: English (Australian), French, Sinhala, Russian, Hebrew
From http://validator.w3.org/i18n-checker/:
Request headers: Accept-Language fr-FR fr en-AU en si ru he
Code: Accept-Language: fr-FR,fr;q=0.9,en-AU;q=0.7,en;q=0.6,si;q=0.4,ru;q=0.3,he;q=0.1
If I set French as the first language, I get:
Accepted: fr-FR
Alternate:
Relevant:
Apparently, it's not possible in all browsers to get the Accept-Language
field without making a request and getting the server to echo the header back to you.
Agreed. I guess it's a trade off. A request could be made but then that shows down decisions that can be made about the languages in the frontend. I can add a request to the library that gets the full proper accepted languages list and makes it available. What do you think?