scratching my head about smth dumb. How can I use ...
# compose
p
scratching my head about smth dumb. How can I use
Locale.current
(
androidx.compose.ui.text.intl.Locale
) with
String.format(locale, ...)
?
is there a way to transform
androidx.compose.ui.text.intl.Locale
to
java.util.Locale
?
I guess?
java.util.Locale(androidx.compose.ui.text.intl.Locale.current.language)
j
What do you
java.util.Locale
for? Taking a look at AndroidPlatformLocale.android.kt it looks like it uses
java.util.Locale
behind the scenes so theoretically you should be able to achieve the same functionality.
But it you needed it, you could probably use something like
java.util.Locale(Locale.current.toLanguageTag())
p
I want to use it when formatting the string for example
String.format(<http://Locale.DE|Locale.DE> "TT %d", System.currentTimeMillis())
s
I use https://github.com/HedvigInsurance/android/blob/7e85f0db5781027e32700587c32c517454[…]core-ui/src/main/kotlin/com/hedvig/android/core/ui/GetLocale.kt instead. Which should also respect things like per-app language settings and invalidates itself properly when there is a configuration change.
👍 1