merono
09/01/2020, 2:52 PMstringResource
doesn’t return a new value when the device language is changed and the activity has android:configChanges="locale|layoutDirection"
declared? It seems to be because stringResource
gets the string from the Context
in the ContextAmbient
, but ContextAmbient
doesn’t change when the Configuration
changes.
I’ve been working around this with something like 👇, but it would be nice if compose handled this for me.
@Composable
fun localizedString(@StringRes id: Int): String {
val context = ContextAmbient.current
val resources = remember(ConfigurationAmbient.current) { context.resources }
return resources.getString(id)
}