WCAG 2.2 success criterion, Level AA
WCAG 3.1.2 Language of Parts
When a passage or a phrase on a page is in a different language from the rest, the code must say so, so that it is read out in the right language.
- Number
- 3.1.2
- Level
- AA
- Added in
- WCAG 2.2
- Guideline
- 3.1 Readable
- Principle
- Understandable
What it asks
3.1.1 Language of Page names the language of the page as a whole. This criterion covers the parts that differ. A French quotation on an English page, a German product description in an English catalogue, or a Welsh name for an organisation beside its English name all need a lang attribute on the element that holds them, so a screen reader can switch voice and pronunciation for that stretch and switch back after it.
The W3C allows four exceptions, and they matter, because most pages are full of foreign words that do not count. Proper names: Paris, Volkswagen, Médecins Sans Frontières. Technical terms: habeas corpus, in vitro. Words whose language cannot be determined. And words that have become part of the surrounding language: café, rendezvous, kindergarten, which an English voice already pronounces as English words.
The usual place this fails is the language switcher. A link that reads "Français" or "Deutsch" is written in the language it leads to, and reads badly in an English voice unless it carries lang="fr" or lang="de". The criterion is Level AA.
Its official name is success criterion 3.1.2 Language of Parts, at Level AA. It was added in WCAG 2.2, under guideline 3.1 Readable and the principle Understandable. The W3C’s normative text says, in part:
“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.”
From WCAG 2.2, W3C. Full explanation: Understanding 3.1.2 Language of Parts.
Who it helps
Screen reader users, who hear a French sentence as a stream of mangled English syllables unless the voice changes. People who use text-to-speech to read, and people who read braille, where the contraction table has to change with the language.
It also helps people who use translation tools, which translate a marked passage correctly instead of treating it as badly spelt English.
What passes and what fails
These pass
- A quotation on an English page wrapped as
<blockquote lang="fr">. - A language switcher whose links are
<a lang="de" href="/de/">Deutsch</a>and<a lang="cy" href="/cy/">Cymraeg</a>. - A bilingual heading where the Welsh is in a
<span lang="cy">. - An English page that mentions Paris, a croissant and a faux pas, with nothing marked. All three are covered by the exceptions.
These fail
- A paragraph of French testimonial text on an English page with no
langattribute. - A language switcher with "Français", "Español" and "Deutsch" as plain links in an English page.
- A footer that repeats the address and legal notice in Welsh with no mark.
<span lang="french">. The value is not a language code, so it marks nothing.
How to test it by hand
- Read through the page and note every passage, phrase or link that is in a language other than the page language.
- For each one, decide whether an exception applies: is it a proper name, a technical term, or a word that English speakers already use as English?
- For the rest, inspect the element in the browser’s developer tools and check for a
langattribute with a valid code for that language. The attribute can sit on the element itself or on any element that contains it. - Check the language switcher, bilingual headings, legal notices and testimonials, which are the places this is most often missed.
- Where you can, listen to the page with a screen reader. A sentence read in the wrong voice is hard to miss.
What automated testing can decide
What a machine can decide
Automated testing can check that every lang attribute on the page carries a valid language code, and can find the elements that are marked. It can also list the passages that seem to be in a language other than the page’s, which gives a reviewer a short list instead of the whole page.
What it cannot
Deciding whether an unmarked passage needs a mark is where the exceptions come in, and they are judgements. Is "Médecins Sans Frontières" a name or a French phrase? Has "schadenfreude" become English? A short phrase gives any tool very little to go on, and a transliterated word gives it nothing at all. The real-world failure is a missing mark rather than an invalid one, and finding missing marks is the hard half.
How Dreven handles it
Dreven finds the passages on your pages that appear to be in another language, and any language marks the page carries, and shows you each one in place.
A reviewer decides whether a passage needs a mark or one of the four exceptions covers it, and the report names each passage, because that is what a developer needs to go and fix.
No automated check makes a site conform. In Dreven, a person reviews the results and signs the report.
Related criteria
- 3.1.1 Language of Page (Level A). The language of the page as a whole.
- 2.4.4 Link Purpose (In Context) (Level A). A language switcher link needs to make its purpose clear as well as being marked in its language.
- 1.1.1 Non-text Content (Level A). An image of foreign-language text needs a text alternative, and that alternative can carry the language mark.
Questions people ask
Do I need to mark single foreign words?
Not usually. Proper names, technical terms and words that have become part of the surrounding language are all exempt, so Paris, habeas corpus and café need nothing. A full phrase or sentence in another language, such as a quotation, does need a lang attribute.
Does the language switcher need lang attributes?
Yes, when each link is written in the language it leads to. A link that reads Deutsch should carry lang="de", so it is pronounced as German rather than as an odd English word.
What is the difference between 3.1.1 and 3.1.2?
3.1.1, at Level A, is about the default language of the whole page, set on the html element. 3.1.2, at Level AA, is about passages within the page that are in a different language from that default.
Can an automated tool find unmarked foreign text?
It can suggest candidates by detecting the language of the text, and it can check that any lang attribute is valid. It cannot reliably decide whether a candidate is a name, a technical term or an adopted word, which is what the exceptions turn on. A person makes that call.