Server-side technologies, including server-side scripting languages and server configuration files for setting HTTP headers.
This technique relates to:
The objective of this technique is to provide information on the primary language or languages in a Web Page, in order to identify the audience of the content. The Content-Language HTTP header can contain a list of one or more language codes, which can be used for language negotiation between a user agent and a server. If the language preferences in a user agent are set correctly, language negotiation can help the user to find a language version of the content that suits his/her preferences.
Note that the Content-Language HTTP header does not serve to identify the language used for processing the content. The content processing language can be identified by means of other techniques, such as the attributes lang and xml:lang in markup languages.
This technique ensures that the primary language of the document, as specified for example in the lang or xml:lang attribute, is listed in the Content-Language HTTP header.
In Java Servlet or JavaServer Pages (JSP), developers can use response.setHeader("Content-Language", lang), in which "lang" stands for a language tag (for example, "en" for English):
Example Code:
…
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
…
response.setHeader("Content-Language", "en");
PrintWriter out = response.getWriter();
…
}
In PHP, developers can send a raw HTTP header with the header method. The following example sets the language to French:
Example Code:
<?php header('Content-language: fr'); … ?>
Resources are for information purposes only, no endorsement implied.
W3C Internationalization FAQ: HTTP and meta for language information
Best Practice 9: Using HTTP or a meta tag to indicate audience in Internationalization Best Practices: Specifying Language in XHTML & HTML Content - W3C Working Group Note 12 April 2007.
Hypertext Transfer Protocol -- HTTP/1.0 (IETF Request for Comments 1945) (plain text)
Hypertext Transfer Protocol -- HTTP/1.1 (IETF Request for Comments 2616) (plain text)
header in the PHP Manual.
Use a Live HTTP Header viewer to find the value of the "Content-Language" header.
Check that this value matches the default language of the Web page.
Step #2 is true.
If this is a sufficient technique for a success criterion, failing this test procedure does not necessarily mean that the success criterion has not been satisfied in some other way, only that this technique has not been successfully implemented and can not be used to claim conformance.
Techniques are informative—that means they are not required. The basis for determining conformance to WCAG 2.0 is the success criteria from the WCAG 2.0 standard—not the techniques. For important information about techniques, please see the Understanding Techniques for WCAG Success Criteria section of Understanding WCAG 2.0.