Hi folks.

Should navigator.language and/or HTTP Accept-Language include my locale in 
addition to my language — even if the combination is exotic?

For example, if I speak English but I like Polish number formatting, should 
navigator.language report “en-pl”?

This question came up in WebKit because ECMA-402’s DefaultLocale() incorporates 
both language and locale and, to avoid confusion, we wanted navigator.language, 
HTTP Accept-Language, and ECMA-402 DefaultLocale() to agree with each other.

Alexey has raised the point that “English as spoken in Poland” / “English with 
a Polish locale” is not a language, and is a potentially surprising value. 
Therefore, it might risk breaking websites.

On the other hand, “en-pl” is a syntactically valid BCP 47 language tag, and 
it’s the only way to avoid incompatibility between code that uses ECMA-402 and 
code that uses navigator.language and/or HTTP Accept-Language.

In researching this question, I discovered that lots of code uses 
navigator.language and/or HTTP Accept-Language to infer the user’s locale, 
despite the fact that language and locale are not equivalent. For example, the 
#1 search result for “infer user locale” is 
<http://www.w3.org/International/questions/qa-accept-lang-locales>, which 
states, "since many applications need to know the locale of the user, common 
practice has used Accept-Language to determine this information”.

Regards,
Geoff

Reply via email to