IEBlog : Accept-Language Header for Internet Explorer 7

IE7 では、Accept-Language: ヘッダの書式が変更されている。


In IE6, most of the choices in the Language Preference list specified a locale-neutral two letter code. For instance fr was sent for French (France), and ja sent for Japanese. Longer codes were only used when a language is commonly spoken in another country or locale-- for instance fr-CA was available for French-speaking Canadians.

For Internet Explorer 7, a change was made such that Internet Explorer will send the full language/locale pair for each locale. IE7 will send fr-FR for French (France) and de-DE for German (Germany). This change enables web servers to more easily target content for a specific language and locale. If a given server is only interested in the user’s language and not the locale, it can ignore the locale portion by simply truncating the code at the first dash.

それに伴い、Apache のコンテントネゴシエーションによる言語セットの自動判別で問題が発生している模様。

手元の IE7 の環境では、Languages の設定は、

  1. 日本語 [ja-JP]
  2. 日本語 [ja]
  3. 英語(米国) [en-US]
  4. 英語 [en]

の順に設定されている。この状態で、例えば http://www.debian.org/intro/about などにアクセスした場合、リクエストヘッダは

Accept-Language: ja-JP,ja;q=0.8,en-us;q=0.5,en;q=0.3

となる。このときのレスポンスヘッダは

Content-Location: about.ja.html
Content-Language: ja

と、日本語のコンテンツを返している。ただし "日本語 [ja]" の優先順位を下げ、

  1. 日本語 [ja-JP]
  2. 英語(米国) [en-US]
  3. 英語 [en]
  4. 日本語 [ja]

の順にして再び http://www.debian.org/intro/about にアクセスしすると、リクエストヘッダは

Accept-Language: ja-JP,en-us;q=0.8,en;q=0.5,ja;q=0.3

レスポンスヘッダは

Content-Location: about.en-us.html
Content-Language: en-us

となり、英語のコンテンツが返却される。
コンテントネゴシエーション機能を使って多言語のコンテンツを管理しているサイトは注意が必要である。日本語環境で使用されている IE で、わざわざ "日本語 [ja]" の優先順位を下げたり削除して使用することも少ないと思われるが…。