With attributed accessibility labels, your app could now, for example, greet your users in different languages. Note that it will change to the voice of the corresponding language you are switching to.

Two examples of a fictional app to teach you new languages. It is showing the user how to greet in the morning in two different languages: “Buenos días” in Spanish and “Buongiorno” in Italian. In code, it sets an accessibilityAttributeLabel to the view with the string and a dictionary containing the accessibilitySpeechLanguage attribute key and the “es-Es” value for Spanish or the “it-IT” value for Italian. The label ends up with the text “Means: good morning”. The language is only applied to the first bit that is not in English.

Example code in the image:

let greetingLessonView = UIView()
let bcp47LanguageCode = "es-Es"
let translatedPhrase = "¡Buenos días! "

let attributedLabel = NSMutableAttributedString(string: translatedPhrase,attributes: [.accessibilitySpeechLanguage: bcp47LanguageCode])

attributedLabel.append(NSAttributedString(string: "Means: good morning!"))

greetingLessonView.accessibilityAttributedLabel = attributedLabel