Re: [whatwg] Should navigator.language and and/or HTTP Accept-Language include locale?

>> 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.
> It confuses me why you would want to have those three to agree.

We want them to agree because old code has been written to infer locale based on navigator.language, while new code will be written to infer locale based on EMCA-402, and we don’t want a webpage to display two distinct localizations simply because two library authors adopted two distinct APIs.

> • navigator.language is the language of the interface
> • HTTP Accept-Language is the language of content

I don’t think this is correct.

As Anne points out later, these two values *should* agree with each other according to HTML.

> • ECMA-402 DefaultLocale() is the user's locale
> To me, these seem like completely different things. For example, I am
> currently on a computer in Germany where LANG is de_DE.UTF-8, but my
> browser uses HTTP Accept-Language to display web sites in English.
>> 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.
> Do you have evidence for web sites being broken by this string?


>> 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.
> What incompatibilities are there? I do not understand this.

Let’s say that my system is set up for English language with Polish locale. ECMA-402 APIs honors this setup. But navigator.language reports “en-us”.

Now I navigate to a news website with ads. The news website author uses navigator.language to infer my locale but the ad author uses ECMA-402. So, all the dates on the news stories display as MM/DD/YYY while all the dates on the ads display as DD/MM/YYYY. This is a bad experience. 

If navigator.language reported “en-pl”, all my dates would display as DD/MM/YYYY. This is a good experience.


Received on Wednesday, 25 May 2016 02:47:01 UTC