Content-Language:

Content-Language: ヘッダー (MIME、HTTP)

[3] Content-Language: ヘッダーは、 対象となるデータの自然言語を表すものです。

仕様書

意味

[34] HTTP における Content-Language: ヘッダーは、 表現の想定読者の自然言語(群)を指定するものです。 これは必ずしも表現中で用いられている言語すべてのリストでなくても構いません。 >>26

[42] HEAD メソッドに対する応答の場合は、 GET だったなら返される表現についての情報を表しています。

[35] このヘッダーの主目的は、利用者が自身の好む (preferred) 言語と表現の言語を比べて識別できるようにするものだ >>26 と説明されています。

[36] このヘッダーが指定されていなければ、すべての言語の読者を対象にしていることを表します。 これは、送信者が特定の自然言語の読者を想定していない場合もあれば、 想定する言語をわかっていない場合もあります。 >>26

[37] 複数の言語を指定して、複数の読者を対象にしていることを示すこともできます。 ただし、表現中に複数の言語が現れるからといって、複数の言語を対象にしているとは限りません。 >>26

[38] 例えば日本語で書かれた「英会話入門」には日本語英語が現れますが、 想定読者は日本語が分かる人ですから、 Content-Language: ja が適当です。

文脈

[27] HTTP では、複数個 Content-Language: ヘッダーを指定できます。

[39] Content-Language: は、テキスト系に限らず、 どんな MIME型にも適用できます。 >>26

構文

[28] MIME でも HTTP >>26 でも、1つ以上の言語タグ, で区切って並べたものとされています。

[29] MIME では字句間に CFWS が挿入できます。

[30] HTTP では、リスト (#) とされています >>26

  1. 言語タグ
  2. *
    1. OWS
    2. ,
    3. OWS
    4. 言語タグ

[7] 言語タグは、 BCP 47 で定義されています。数世代の RFC があり、途中で非互換変更も行われています。どの版が参照されているかは、 MIMEHTTP の仕様書の版によっても異なっています。

[31] 詳しくは言語タグの項を参照してください。

異体説明 language 異体属性

[2] 異体説明language 異体属性は、 Content-Language: ヘッダーに相当するものです >>1

構文

[43] 属性値は、1つ以上の言語タグリスト (#) です >>1

  1. 言語タグ
  2. *
    1. OWS
    2. ,
    3. OWS
    4. 言語タグ

DAV:getcontentlanguage 特性 (WebDAV)

[45] DAV:getcontentlanguage 特性は、 accept header なしで GET した時に返されるであろう Content-Language: ヘッダーの値を表します >>44

[52] Content-Language: ヘッダーを返す WebDAV に従う資源はすべて DAV:getcontentlangauge 特性を定義しなければなりません >>44

[47] 値は言語タグです >>44

  1. 言語タグ

[48] ヘッダーの値が OWS を含む場合には、 これを除去して特性値として使うべきです >>46

[49] 保護特性とするべきではありません >>44

[50] RFC 2518 時代のは、保護特性としているかもしれません >>44

[51] COPYMOVE でも値が保持されるべきです >>44

歴史

[25] 元々 RFC 1766 で定義されていました。

[54] 末、 新しい RFC 3282 により再定義されました。

[8] HTTP も別途定義しています。

RFC 1766

[21] RFC 2130 はこの Content-Language と同様の形式による自然言語の指定を他のプロトコルでも (必要なら) 使うことが好ましいと述べています。

[20]

The specification technique should be a MIME identifier with IANA registered values for languages. If headers are used, the header should be 'Content-Language'.

RFC 2130 - The Report of the IAB Character Set Workshop held 29 February - 1 March, 1996 ( 版) http://tools.ietf.org/html/rfc2130#page-12

HTTP

RFC 1945 (HTTP/1.0) D.2.5; (HTTP/1.1) RFC 2068 14.13; RFC 2616 14.12 Content-Language

The Content-Language entity-header field describes the natural language(s) of the intended audience for the enclosed entity. Note that this {1945,2068} may {2616} might not be equivalent to all the languages used within the entity-body {2068,2616}.

Content-Language 実体頭欄は、 囲まれた実体の想定視聴者の自然言語を記述します。 これは entity-body 中で使われている全ての言語と等しくないかもしれないことに注意して下さい。

{2068,2616}

  • Content-Language = "Content-Language" ":" 1#language-tag

Language tags are defined in section 3.10. The primary purpose of Content-Language is to allow a user to identify and differentiate entities according to the user's own preferred language. Thus, if the body content is intended only for a Danish-literate audience, the appropriate field is

言語札は 3.10 節で定義しています。 Content-Language の主たる区的は、利用者が利用者自身の優先言語に従って実態を識別・差別化することを可能とすることにあります。 従って、本体内容がデンマーク語が分かる視聴者のみを想定しているのであれば、 適切な欄は

  • Content-Language: da

If no Content-Language is specified, the default is that the content is intended for all language audiences. This may might mean that the sender does not consider it to be specific to any natural language, or that the sender does not know for which language it is intended.

Content-Language が指定されていなければ、既定値はその内容がすべての言語の視聴者を想定しているになります。 これは、送信者がそれが何らかの自然言語に特有のものであると考えていないか、 送信者がどの言語が想定されているのか知らないことを意味するでしょう。

Multiple languages MAY be listed for content that is intended for multiple audiences. For example, a rendition of the "Treaty of Waitangi," presented simultaneously in the original Maori and English versions, would call for

複数の視聴者を想定している内容については、複数の言語を列挙しても構いません。 例えば、 Treaty of Waitangi の翻訳で、 元のマオリ版と英語版が並行して示されているなら、

  • Content-Language: mi, en

となるでしょう。

However, just because multiple languages are present within an entity does not mean that it is intended for multiple linguistic audiences. An example would be a beginner's language primer, such as "A First Lesson in Latin," which is clearly intended to be used by an English-literate audience. In this case, the Content-Language should would properly only include "en".

しかし、ただ単に実体中に複数の言語が示されていることは複数の言語の視聴者を想定していることを意味しません。 例えば、初めての言語入門書, 例えば『A First Lesson in Latin』のような明らかに英語の分かる視聴者に使われることを意図したものを考えましょう。 この場合だと、 Content-Languageen だけを含めるのが適当でしょう。

Content-Language may MAY be applied to any media type -- it is not limited to textual documents.

Content-Language はどの媒体型に適用してもかまいません。 文的文書には制限しません。

RFC 3282

[32] MIME 側の定義が独立する形で新しい版が発行されました。

[33] HTTP にも適用することをほのめかすような記述もありましたが不明瞭でした。 HTTP の改訂版である RFC 7231 は、 RFC 3282 を参照していないで独自に定義しています。

<meta http-equiv=Content-Language>

[14] よく、 HTML文書<meta http-equiv="Content-Language" content="ja"> のように言語を指定すれば文字化けしなくなるなどと適当な解説がされていますが、まったく意味がありません

http-equiv は本来が解釈するものでしたが、 そうするように設定されているはほとんどありません。 Webブラウザが解釈することもありますが、 保障されているわけではありませんでした。 本当の HTTP 頭欄としての Content-Language: を指定するか、 HTML要素lang を指定するのが適切なやり方です。

いずれにしても、文字コードとはまったく関係ありません。 文字化けがなくなるなどと解説している文書は信用してはいけません。

[15] <meta http-equiv="Content-Language"> (Ian Hickson 著, 版) http://lists.w3.org/Archives/Public/public-html/2008Dec/0032.html

<meta http-equiv=Content-Language> は不適合になりました。

[16] (X)HTML5 Tracking ( 版) http://html5.org/tools/web-apps-tracker?from=4336&to=4337

[17] Web Applications 1.0 r5980 8088 ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5979&to=5980

関連

[40] 文書に含まれる要素言語の決定には lang 属性が使われますが、文書要素にも明示されていない場合、 Content-Language: ヘッダーがあれば、その値が採用されます。

メモ

[22] Web Applications 1.0 r7283 Change Content-Language pragma to obeying the last pragma, not the first, as this is closer to what Firefox, IE9, and WebKit do. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7282&to=7283

[23] Web Applications 1.0 r8389 Mention that the content-language pragma intentionally ignores words after the first (hopefully browsers end up matching this... they vary in their behaviour today) ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8388&to=8389

[24] IRC logs: freenode / #whatwg / 20140115 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20140115#l-249

[41] 文書中の JavaScript から Content-Language: ヘッダーにはアクセスできないので、 Content-Language: を使うより文書要素lang 属性に指定する方が好ましいと考える人もいます。

[53] Strengthen requirements on CORS-safelisted request-headers (annevk著, ) https://github.com/whatwg/fetch/commit/9288c8f85c809a0ac371be6843ad2cf4046ee35b