So, LocalConfiguration is a composition local. It's only intended for reading values that are supplied higher up in the composition hierarchy.
What you can write is this:
Copy code
val configuration = LocalConfiguration.current
configuration.setLocale(locale)
CompositionLocalProvider(LocalConfiguration provides configuration) {
// everything here "sees" the updated configuration
}
This will only use the updated configuration for composables that are in that composition local provider. Everything outside will still see the normal configuration.
I think that method is deprecated because you really shouldn't be setting the configuration app-wide. If you want that updated locale for all of your stuff, then just make sure to include that composition local provider super high up in your composition hierarchy, so that everything in your app is "underneath" it.
Nathaniel Rowe
02/12/2022, 10:19 PM
Actually, you probably wanna do something like
val updatedConfiguration = remember { configuration.setLocale(locale) }
. Sorry, I'm not super good with the whole "remember" concept.