🎉 Requestly joins BrowserStack to build the future of application testing. Read more

HTTP Headers

Content Language

HTTP Header

The HTTP Content-Language representation header is used to specify the language(s) that the content is intended for, allowing users to identify and select the language most suitable for them.

For instance, Content-Language: de-DE indicates that the document targets German speakers. The document’s actual language may be different, such as English, especially if it serves as a language course for German speakers. To specify the language in which the document is written, use the lang attribute instead.

If no Content-Language header is present, the default assumption is that the content is meant for audiences of all languages. It is also possible to specify multiple language tags, and the header can apply to various media types, not just textual content.

The Header type is a Representation header. It is not a forbidden request header but is a CORS-safe response header and a CORS-safe request header, with some restrictions.

Values for headers allowing multiple entries can include only the characters 0-9, A-Z, a-z, space, or the characters *,-.;=.

Syntax

Below are examples of setting the Content-Language header:

Content-Language: de-DE
Content-Language: en-US
Content-Language: de-DE, en-CA

Directives

language-tag

Multiple language tags are separated by commas. Each language tag is a sequence of one or more case-insensitive subtags, each separated by a hyphen (-). Typically, a language tag begins with a primary language subtag that identifies a broad family of related languages (such as en for English). It may be followed by additional subtags that specify a particular variety or dialect, like en-CA representing Canadian English.

Example

The global lang attribute is used on HTML elements to indicate the language of an entire HTML document or parts of it.

The lang attribute helps browsers, search engines, and assistive technologies identify the language of the content, enabling appropriate language-specific rendering and accessibility features.

For example, to specify that a webpage is written in German, use the attribute as follows:

<html lang="de">...</html>

<meta http-equiv="content-language" content="de" />

Indicating a target audience for a resource

The Content-Language header is used to specify the intended audience of a page and can include multiple languages, indicating the content is suitable for speakers of those languages.

This header can be included in HTTP responses to inform user agents about the languages of the content, such as:

Content-Language: de, en

How to Modify Header using Requestly

Requestly is a handy Chrome extension that makes it easy to modify HTTP headers, including the Content-Language header. This helps developers check how their application handles different language preferences by simulating requests with various language settings. Steps to Modify the Content-Language Header:

  1. Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
  2. Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
  3. Add a new header modification:
    • Under “Action”, select “Add” or “Override”.
    • In the “Header Name” field, enter Content-Language.
    • In the “Header Value” field, enter your preferred language code (e.g., en-US).
  4. Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
  5. Save the rule.

Once set up, Requestly will inject the Content-Language: en-US header into all matching requests, allowing you to test how your server delivers content for different language preferences.