Content-Language
The Content-Language header indicates the primary (natural) languages that the document is written in. (This does not refer to computer languages; see Content-Type instead.) Using a language tag implies the target audience is capable of reading one of the languages listed.
The value is one or more RFC5646 language tags identifying a language, one of which the audience must be able to understand.
Writing requests (clients)
Clients can send this in requests containing a message body. Send this if the media type doesn't have a way of conveying the content's language (e.g. plain text), and server is known to use it in some fashion. For example, document databases might store the Content-Language header of uploaded documents, and use it to assist with indexing, as well as send back the same header when the document is retreived.
Reading requests (servers)
Servers can use the Content-Language header for applications where the written text of the uploaded document is being processed, and the document's media type does not have a way, or does not specify, a language. For example, any natural language processing, or fulltext indexes. If the document is being saved, e.g. on a filesystem, try to save the language header and preserve it for subsequent requests. Note that language tags are case-insensitive, but it is not necessary to normalize a valid language tag, the downstream processor should be able to use the language tag as-is.
Writing responses (servers)
Servers should send a Content-Language header if the primary language of the document is known. If the server has saved a language in the database, or if the document specifies a language (e.g. in an xml:lang
or HTML lang
attribute), then generate a language tag (or verify the existing langtag) and send it in a Content-Language header.
While applications increasingly detect the language of a document without a machine label, in some cases this is impractical. For example, negotiating gateways and caches might select a document based on the user's language preferences.
Reading responses (clients)
Note this value may be influeuenced by the Accept-Language header; if this is the case, the server will usually send Vary: Accept-Language
in the response.
Offering translations
Alternate versions of a document can be specified using a link, either the Link header or a link , such as the <link/>
element in HTML; by using rel="alternate"
and hreflang="target-language"
. User agents can use this link to suggest translations to users. See the HTML specification for more information.
Overview table
- Name
- Content-Language
- Description
- Indicates the (written) language of the document.
- Direction
- Both
- Negotiated by
- Accept-Language
- Specification
- RFC 7231: HTTP/1.1 Semantics and Content ยง3.1.3.2. Content-Language
Syntax
Content-Language = 1#language-tag
language-tag = <Language-Tag, see [RFC5646], Section 2.1>
Language-Tag = langtag ; normal language tags
/ privateuse ; private use tag
/ grandfathered ; grandfathered tags
Example
Content-Language: mi, en