How do I say "this text is in this language" in Jetpack Compose so the screenreader reads it correctly? 🤔
Important for apps that show texts in multiple languages.

#Android #Compose #JetpackCompose #Kotlin #Androiddev

@ConnyDuck Create an AnnotatedString and surround the text with a SpanStyle specifying the "localeList" argument.

val text = buildAnnotatedString {
withStyle(SpanStyle(localeList = LocaleList("fr"))) {
append("Bonjour !")
}
}

@bladecoder Nice, that definitely helps but a solution that would work with content descriptions as well and doesn't need changing every Text would be even better.
@ConnyDuck Unfortunately it's not possible to scope a composable to a locale (yet?). LocalLocaleList was introduced recently but it's read-only and can't be overridden.
And setting the LocaleList on a Text style seems to have no effect on accessibility.