If compose can handle recomposing for configuratio...
# compose
m
If compose can handle recomposing for configuration changes, is it considered a bug that
stringResource
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.
Copy code
@Composable
fun localizedString(@StringRes id: Int): String {
    val context = ContextAmbient.current
    val resources = remember(ConfigurationAmbient.current) { context.resources }
    return resources.getString(id)
}