http-headers

Accept-Language: (Request)

Introduction#

Accept-Language tells the server what language (such as English) does the client accept.

Syntax#

  • Accept-Language: Language;QualityFactor
  • Accept-Language: Language;QualityFactor, Language;QualityFactor, …
  • Accept-Language: *

Parameters#

Parameter Description
Language What language is acceptable.
QualityFactor The quality factor in the format ;q=0.8 (optional)
* Match any language

Remarks#

Accept-Language takes a number of languages and includes an optional preference for which one the server should use. The language is one from the list of available at IANA Language Subtag Registry page. For example en is English, and en-US is USA English.

The language is separated by commas with an optional quality factor (using a ;q=) that is used the clients preference for using this language. The quality factor has a value from 0 to 1 with the higher the number the more preference for that language.

If this header is not included then the client will accept any language.

The server uses Content-Language to inform the client what langauge it is using.

English only

Request:”https://example.com

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html
Accept-Language: en
Accept-Encoding: gzip, deflate
Connection: keep-alive

The client will only accept Content-Language of English.

US English or basic english

Request:”https://example.com

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive

The client will accept English but prefers US English.

US English or basic english

Request:”https://example.com

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html
Accept-Language: da, en-gb;q=0.8, en;q=0.7
Accept-Encoding: gzip, deflate
Connection: keep-alive

The client prefers Danish, but will also accept British English, or if that’s not available basic English.

Match any language

Request:”https://example.com

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html
Accept-Language: *
Accept-Encoding: gzip, deflate
Connection: keep-alive

The client will accept any language.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow