Stylianos Gakis
01/17/2023, 9:18 AMLocale in compose right? I can see Locale is there, which only gives you a way to fetch the locale, not to update it, and looking at the implementation it doesn’t seem to use the AppCompatDelegate.setApplicationLocales aka the Per-App Language Preferences API.
Oh and also it doesn’t give a java.util.Locale so there’s that.
Am I missing something here? How do you folks typically fetch the proper locale in your composables aside from just passing it down the chain all the way through?ephemient
01/17/2023, 9:31 AMLocalContext.current.resources.configuration.localesephemient
01/17/2023, 9:32 AMAlbert Chang
01/17/2023, 9:32 AMLocalConfiguration.current.locales.Albert Chang
01/17/2023, 9:33 AMStylianos Gakis
01/17/2023, 9:41 AMLocalConfiguration.current.locales instead of LocalContext… right? Not in addition to it I assume.
Also with that said, I assume both of these do not interact with the per-app language APIs, do they? Like if I use those APIs to manage my locale, do you know if that will update the locales inside LocalConfiguration?Stylianos Gakis
01/17/2023, 10:13 AMLocalConfiguration.current.locales requires API 24 or newer though 😵 Is this fixable in some way, with coreLibraryDesugaring or something like that? If not I guess I need to make my own LocalLocale and make sure I am also subscribing to LocalConfiguration.current myself to react to such config changes.Stylianos Gakis
01/17/2023, 10:14 AM.locale works fine but is deprecated over .locales which is >API24 only. Anyway, gonna use the deprecated one then.Albert Chang
01/17/2023, 10:15 AMConfigurationCompat.getLocales(LocalConfiguration.current)
And I believe per-app language API should also update the configuration.Stylianos Gakis
01/17/2023, 10:19 AMval locale = ConfigurationCompat.getLocales(LocalConfiguration.current)[0]
This seems to cover all Android versions and I will just double check that it follows the per-app language APIs too.