Using the correct ISO language marker matters
How to improve ease of content comprehension for screen reader users
Fun fact not super well known about screen readers: The Lang attribute you use matters.
Well, it's not super well known by people who don't use screen readers regularly!
It's in the accessibility standards
One of the things we find in WCAG is that we need to declare the language of a page (SC 3.1.1) and the language of parts (SC 3.1.2). This is typically done using the lang attribute and an ISO language code.
For example, if the page is in English, the ISO code would be "en". If the page is in French, it would be "fr". If the page is in Spanish, it would be "es". You can find a list of ISO language codes on Wikipedia.
But why?
It's important to declare a language so the screen reader knows how to pronounce what's on the page properly.
It makes for sometimes hilarious pronunciation when I do accessibility testing with a screen reader and come across a page in French, and the language hasn't been declared.
Hilarious from a testing perspective. But frustrating from a daily user of screen reader who relies on this.
So, yes, declaring the language of the page is extremely important. And declaring changes of *parts* of a page is just as important.
But wait, there's more!
We also have to make sure we use the correct ISO language code to declare the language.
A screen reader user once explained to me what problems might happen if you use localized ISO code. For example, instead of using lang="en", you'd use lang="en-us", or lang="en-gb". This determines a specific localization of the language. And as this user explained, he's used to listening to pages at a very high speech rate. If you force his screen reader to read and pronounce things slightly differently because you're using a specific locale, it will throw him off. He'll have to slow down his screen reader.
Is this a blocker? Absolutely not. Not at all like not declaring language at all. Is this an annoyance? Yes! Does it affect all screen reader users? Absolutely not. Does it annoy the ones who are affected? You bet!
And this is why for accessibility I typically recommend veering away from localized ISO language declarations.
Recap
Make sure to declare the language of your page, and declare the changes in language on your page. But make sure to use only the 2 letter ISO code without localization.
In addition to the correct ISO code for the lang attribute, sighted users will appreciate the right-to-left direction attribute for languages such as Arabic. See my post "Inclusive design transcripts for a video component" https://vfowler.com/inclusive-design-transcripts-video-component/#more-transcripts-for-more-languages