Success Criterion 3.1.2 - Level AA
Language of Parts
Ensure assistive technologies can switch between languages when content is written in multiple languages. When you include a French quote in a Dutch text, the language of the quote must be set in French. This allows assistive technologies to read the quote in the correct language. You do not have to set the language for individual words such as "crème fraîche".
Impact
Ensure the language of text written in other languages is set correctly.
People with screen readers can have parts of text read in another language.
Check
“Are foreign texts indicated in their respective language?“
This can be tested with the screen reader.
Note: this success criterion is exempt for apps in EN 301 549.
Solution
Set language of text
On Android, you can use LocaleSpan
to speak content in a specific language. Multiple LocaleSpan
's can be embedded inside a SpannableString
to speak content in multiple languages.
val locale = Locale.forLanguageTag("nl-NL")
val localeSpan = LocaleSpan(locale)
val string = SpannableString("Appt")
string.setSpan(localeSpan, 0, string.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
element.setText(string)