Is there an HTTP / HTML header / meta tag that I can use to advertise the supported Content-Language?
just wondering if there is a mechanism to "advertise" what values ββI can take in Accept-Language and return the correct Content-Language.
There is a link "Link :; rel = alternate hreflang = pt-br" but that forces me to create a new resource (as opposed to exposing the same resource in a different language).
http://www.w3schools.com/tags/att_link_hreflang.asp
Here's a related question:
source to share
Ideally, this should be done in HTTP headers - you guessed it, HTML tags aren't really the place for this.
About the Content-Type header, from the IETF:
The Content-Language header can map multiple languages ββto a split list.
Thus, the purpose of the header Content-Language
is to display ALL possible languages ββfor the current resource, not just the language of the page you are serving.
To advertise accepted languages, add them to your title Content-Language
.
For example, also from the IETF :
An official European Commission document (in a few of its official
languages):
Content-type: multipart/alternative
Content-Language: da, de, el, en, fr, it
source to share
You can achieve this effect with an HTML tag that it uses http-equiv
to represent the HTTP header you wanted.
<meta http-equiv="accept-language" content="de, en">
<meta http-equiv="content-language" content="de">
However, as mentioned in this question , this is indeed the "poor" approach to it, and you should instead supply the proper HTTP header:
Content-Language: de
Accept-Language: en, de
If you just want to indicate which language the webpage is in, you can also use <html lang="de">
.
Edit: If you want to express this correctly in headers, you can do so by putting a PHP code snippet at the top of the file:
header('Content-Language: de');
header('Accept-Language: de, en');
source to share