Rene Win
03/08/2023, 1:28 PM@Preview(locale = "en")
then i assume that some code (in this example Locale.getDefault()) would also return this locale.
but it doesnt matter what i put in their, the Locale.getDefault() always returns the (i assume) system language
full preview code for completeness:
@Preview(locale = "en")
@Composable
fun Test() {
Text("${Locale.getDefault()}")
}
The reason behind this is that we use the previews for screenshot testing and we have a datetimeformatter which depends on the current locale.. (which is calling Locale.getDefault() in the background)Stylianos Gakis
03/08/2023, 1:30 PM@Composable
@ReadOnlyComposable
fun getLocale(): Locale {
val configuration = LocalConfiguration.current
return ConfigurationCompat.getLocales(configuration).get(0) ?: LocaleListCompat.getAdjustedDefault()[0]!!
}
And see if this returns the right locale, I’m also curiousRene Win
03/08/2023, 1:39 PMcontext.resources.configuration should be the same as LocalConfiguration.currentephemient
03/08/2023, 1:41 PMLocalView.current.context == LocalContext.current
LocalContext.current.resources.configuration == LocalConfiguration.currentStylianos Gakis
03/08/2023, 1:41 PMephemient
03/08/2023, 1:43 PMLocalView.current and LocalContext.current won't change, but LocalConfiguration.current willStylianos Gakis
03/08/2023, 1:45 PMLocalContext.current.resources.configuration you're going to be getting stale information about the configuration? Or did I misunderstand you?ephemient
03/08/2023, 1:45 PMLocalContext.current.... may be outdated because it doesn't that part of the context has mutatedyschimke
03/08/2023, 7:09 PMephemient
03/08/2023, 7:10 PMephemient
03/08/2023, 7:11 PMephemient
03/08/2023, 7:11 PMLocale.setDefault() isn't observable)yschimke
03/08/2023, 7:13 PMStylianos Gakis
03/08/2023, 7:14 PMStylianos Gakis
03/08/2023, 7:15 PM