16. Human Language
Specify the human language (e.g. Arabic, Chinese, English) of text
Indicate human language (e.g. Arabic, Chinese, English) following conventions for the media type.
Rationale
This helps screen readers to use the correct reading and pronunciation conventions for the language.
General Techniques
The first step to meeting this guideline in any media type is to look up an appropriate language code for the main language used. Some common language codes are provided below:
Language Language Code(Required) Language Code with Sub-code(Use if you wish to specify a regional dialect) Chinese(Simplified) zh-CHS Chinese(Traditional) zh-TW Czech cs Danish da English en English (US) en-US English (Canada) en-CA English (UK) en-UK Finnish fi French fr French(Quebec) fr-CA-QC German de Hindi hi Hungarian hu Italian it Japanese ja Korean ko Norwegian no Polish pl Portuguese pt Russian ru Spanish es Spanish(Latin America) es-419 Spanish(South America) es-005 Swedish sw Turkish tr No Linguistic Content zxx Computer code / Mark-up Use whatever language the comments are in. If there are no comments use whatever human language the code is based on. For example, HTML is based on English.
For additional codes and for details on how language codes are constructed see: (See Technology Specifics for information on how to apply the tags.)
- W3C Internationalization Activity’s article on Language Tags: This Window | New Window
- The Internet Society, Network Working Group, Best Current Practice 47: This Window | New Window
- If the media contains changes in language or in regional dialect, look up appropriate language codes for those languages as well. (See Technology Specifics for information on how to apply the tags.)
- Do not assign specific language codes for proper names even if the language of origin differs from surrounding text.
- Do not assign specific language codes for words from other languages that have become a part of the language of the surrounding text. For example, when appearing within English sentences the following words should NOT be marked as Japanese: dojo, ninja, haiku, kimono, and sashimi.
Technology Specifics
HTML | XHTML | CSS
- In the opening HTML tag add a language attribute as follows:
In HTML use the
lang
attribute.<html lang=“en”>
In XHTML 1.0 use both the
lang
andxml:lang
attributes. XHTML 1.0 can be served as either text/html or xml. If XHTML is served as text/html, it requires both attributes. Since content maybe be reused on varying servers, it is safest to use both attributes.<html xmlns=“http://www.w3.org/1999/xhtml" lang=“en” xml:lang=“en”>
In XHTML 1.1 use
xml:lang
, as it is not valid to serve XHTML 1.1 as text/xml.<html xmlns=“http://www.w3.org/1999/xhtml" … xml:lang=“en”>
Add language attributes for any content whose language is different from the default language of the page. The attribute can be added to any tag:
<!– xhtml 1.0 –> <p lang=“de” xml:lang=“de”>Wenn Sie in der Textantwort einen Absatz erzeugen möchten, geben Sie am Anfang des Absatzes und am Ende des Absatzes ein.</p>
If needed, add a span tag to enclose just the text that is in the additional language:
<!– html –> <p>He said, <span lang=“fr”>“Bonjour!”</span>, which was a surprise since they didn’t know he could talk.</p>
JavaScript
If content is changed or added, or, in particular, translated, update the language attributes as well:
/* html French */
document.getElementsByTagName(‘html’)[0].lang = ‘fr’;
/* xhtml 1.1 English */
document.getElementsByTagName(‘html’)[0].setAttribute(‘xml:lang’,‘en’);
Android Applications
Android applications can set the default language using the Locale class. The languages supported are English, French, Chinese, German, Italian, Japanese and Korean.
iOS Applications
The language for interface elements is set using the accessibilityLanguage
property. For every language supported, a localized label or text can be provided. Voiceover by default speaks the language that the user specifies in the International property settings.
VoiceOver supports the following languages: Arabic, Chinese (Cantonese), Chinese (China), Chinese (Taiwan), Czech, Danish, Dutch, English (Australia), English (Britain), English (Irish), English (South African), English (United States), Finnish, Flemish (Belgian Dutch), French (Canadian), French (France), German, Greek, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese (Brazil), Portuguese (Portugal), Romanian, Russian, Slovak, Spanish (Mexico), Spanish (Spain), Swedish, Thai, Turkish.
PDF in Acrobat
Within the PDF document, both the document language and any changes of language within the document can be specified.
Setting the Document Language
To indicate the primary document language, go to the document properties at File > Properties. On the Advanced tab there is an option to select the language. Choose the appropriate language in the drop-down list. If the language is not in the drop down list, type the language code into the field that has the drop down.
Changes of Language within a Document
If the document contains text in a language other than the primary document language, that text needs to be defined as the appropriate language. The easiest way to do this is to find the tag that contains the text. Right-click the tag and select Properties in the context menu. In the tags tab, the properties dialog has an option to select the language from a drop-down list. If the language is not in the drop down list, type the language code into the field that has the drop down.
If there is a word or phrase within a sentence that needs to be defined as a different language, first split the original content using the TouchUp Reading Order (TURO) tool. This will create three tags. Check to make sure the tags are in the correct order and set the language of the text. All three tags should be at the same level beneath the parent tag.
Word
In Word, set both the primary document language and any changes in language within the document.
Document Language
- Word 2010 reports the document language to assistive technology. Set this in File > Info > Properties (a dropdown) > Show Document Panel.
- In Word 2007, set the language in Office Button > Prepare > Properties > Custom, but this is not reported to assistive technology.
Changes in Language
To set the language of text within a document, use the “Set Language” option on the Review tab, in the proofing group.
If the language is not listed, install the language pack for that particular language. For more information, see the Microsoft help: Determine if you need a language pack.
PowerPoint
A screen reader will read content in the default language of the system unless a document identifies another language. If it tries to identify and read English words in German content, the result can be less than useful for the user.
PowerPoint 2010 reports the document language to assistive technology. Set this in File > Info > Properties (a dropdown) > Show Document Panel.
In PowerPoint 2007, you can, and should set the language in Office Button > Prepare > Properties > Custom, but this is not reported to assistive technology.
Testing HTML
Testing technique | Description |
---|---|
Observation Techniques & Tools | First, we need to see how many language tags are required and what their values need to be. Note the primary language of the entire page. Next, skim the page looking for any changes in language. Second, we need to see where the language has been set. In the Web Accessibility Toolbar (WAT) use Doc Info > Show Lang Attributes. If not using WAT, view the page source and search for “lang”. |
Output | The WAT function displays all of the In the WAT toolbar, In View Source, |
Analysis | Make sure that the language of the page has been specified. If there are language changes on the page, the sections that have a different language from the overall page language will need The required version of the
|
Testing Mobile Applications
Testing technique | Description |
---|---|
Tools | Use the screen reader (VoiceOver on iOS and TalkBack on Android) to evaluate language. |
Review | Note any text on the page that is in different language than the primary language set on the device. Read the page with the screen reader. |
Analysis | Check that the text is read in the correct dialect for the language. Note: you may need to download the language packs first if they are not already installed. |
Testing PDF in Acrobat
Testing technique | Description |
---|---|
Tools | Use the Acrobat File > Properties dialog, Advanced tab, to verify that the language has been set. When a different language is used for specific text, verify that the text is contained in a separate tag, whose properties indicate the proper language. |
Output | Inspect the setting to ensure that it is correct. The Accessibility Full Check will also report if there is no language specified for the document. |
Analysis | Make note of any text that is not associated with the proper language, and indicate if the document does not specify the language. |
Related Guidelines
WCAG 2.0 Level A - SC 3.1.1 Language of Page:
The default human language of each Web page can be programmatically determined. (Level A)
WCAG 2.0 Level AA - SC 3.1.2 Language of Parts:
The human language of each passage or phrase in the content can be programmatically determined except for proper names, technical terms, words of indeterminate language, and words or phrases that have become part of the vernacular of the immediately surrounding text. (Level AA)