W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2016

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

From: Geoffrey Garen <ggaren@apple.com>
Date: Mon, 23 May 2016 14:58:47 -0700
Message-id: <96114F33-242C-497B-94AC-17B70B9D93DC@apple.com>
To: WHAT Working Group <whatwg@whatwg.org>
Cc: Phil Pizlo <fpizlo@apple.com>, Alexey Proskuryakov <ap@apple.com>
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
Received on Monday, 23 May 2016 21:59:14 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:38 UTC