Skip to content
Andrew Hick edited this page Jun 6, 2023 · 4 revisions

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.

When this is applicable

Always.

Check correct language

Read the whole content, including content within iframes. This is easier on short pages. On long pages it helps to extract all unique words using tools like Word List Maker or Unique Word Extractor and check that list instead.

Use the Lang bookmarklet to show all sections that are marked up in a different language. Use the Unframe iFrames bookmarklet to open all the iframes in a new window or tab. Then use the Lang bookmarklet on those.

Check any words in a different language from the main language have:

  • an element around those words with a lang attribute and that it's set to the correct language - in X(HT)ML it might also have a xml:lang attribute, which should have the same value
  • a valid lang attribute (ISO 639-1 2-letter codes) - it is also valid if the value is split into a main language and a sub language, for example "en-gb" for British English or "en-us" for American English

If you're not familiar with the word, search for it online or use a dictionary to find out its language.

Exceptions

  • words which would be pronounced the same in the main language do not need to have a different lang
  • words which are loan words from another language but accepted as part of the main language do not need a different lang - for example 'espresso', 'bazaar' or 'haiku'
  • be lenient if single foreign words are not declared if they could be understood in context
  • proper names
  • technical terms
  • words that do not belong to any single known language, for example onomatopoeia like 'shhh' or 'kaboom'

Best practice

  • Be lenient if the majority of foreign words have declared the correct lang but a few have been forgotten - 90% is good, 50% would be a fail
  • Using hreflang on links is a good idea to indicate the language of the target page

Mobile app testing

Languages cannot be reliably checked at this time for native apps.

In a browser, a screen reader will switch to the language set by the page, if it is available on the device.