Skip to content
Related Articles

Related Articles

Improve Article
HTTP headers | Accept-Language
  • Last Updated : 31 Oct, 2019

This HTTP Accept-Language header tells the server about all the languages that the client can understand. With the help of content negotiation, there will be a set of supported languages in the HTTP Accept-Language proposal then the server selects one of the proposals of those languages and place that in the content-language header. In a few cases users can change the languages manually otherwise server detects the supported language by the browser’s language. But remember one thing that it is recommended that the server never overrides an explicit decision. If the user is comfortable with a language that does not list on the server language then the server can not serve the matching language to the client in that case 406 Not Acceptable status code will be sent.

Syntax:

  • This is the specific language selection syntax.
    Accept-Language: <language>
  • This syntax works as a wild card (selects all languages).
    Accept-Language: *

Note: Multiple languages can be listed by using commas and the optional.
Directives: This header accepts two directives as mentioned above and described below:

  • <language>: This consists of a 2-3 letter base language tag representing the language, followed by sub-tags separated by ‘-‘ . The extra information is the region and country variant (like ‘en-US’ or ‘fr-CA’)
  • *: It is used as a wildcard for any language present.

Note: The ;q= it defines the factor weighting, value placed in an order of preference expressed using a relative quality value
Examples:

  • In this example single value is on Accept-Language header that is English of US.
    accept-language: en-US
  • In this example double value is on Accept-Language header that is English of US and French of Canada.
    Accept-Language: en-US,fr-CA
  • In this example single value is on Accept-Language header that is English of US with the factor weighting.
    accept-language: en-US,en;q=0.9

    To check this Accept-Language in action go to Inspect Element -> Network check the request header for Accept-Language like below, Accept-Language is highlighted you can see.

    Supported Browsers: The browsers are compatible with HTTP Accept-Language header are listed below:

    • Google Chrome
    • Internet Explorer
    • Firefox
    • Safari
    • Opera
    My Personal Notes arrow_drop_up
  • Recommended Articles
    Page :