diff --git a/core/src/commonMain/kotlin/ca/gosyer/jui/core/lang/Locale.kt b/core/src/commonMain/kotlin/ca/gosyer/jui/core/lang/Locale.kt index 5da9730b..7a5db548 100644 --- a/core/src/commonMain/kotlin/ca/gosyer/jui/core/lang/Locale.kt +++ b/core/src/commonMain/kotlin/ca/gosyer/jui/core/lang/Locale.kt @@ -8,8 +8,6 @@ package ca.gosyer.jui.core.lang import androidx.compose.ui.text.intl.Locale -expect fun Locale.Companion.getDefault(): Locale - expect fun Locale.getDisplayLanguage(displayLocale: Locale): String expect fun Locale.getDisplayName(displayLocale: Locale): String diff --git a/core/src/jvmMain/kotlin/ca/gosyer/jui/core/lang/JvmLocale.kt b/core/src/jvmMain/kotlin/ca/gosyer/jui/core/lang/JvmLocale.kt index eacf0756..54bc9a3c 100644 --- a/core/src/jvmMain/kotlin/ca/gosyer/jui/core/lang/JvmLocale.kt +++ b/core/src/jvmMain/kotlin/ca/gosyer/jui/core/lang/JvmLocale.kt @@ -9,9 +9,7 @@ package ca.gosyer.jui.core.lang import androidx.compose.ui.text.intl.Locale import java.util.Locale as PlatformLocale -actual fun Locale.Companion.getDefault(): Locale = current - -fun Locale.toPlatform() = PlatformLocale.forLanguageTag(toLanguageTag()) +fun Locale.toPlatform(): PlatformLocale = PlatformLocale.forLanguageTag(toLanguageTag()) actual fun Locale.getDisplayLanguage(displayLocale: Locale): String = toPlatform() .getDisplayLanguage(displayLocale.toPlatform()) diff --git a/data/src/commonMain/kotlin/ca/gosyer/jui/data/catalog/CatalogPreferences.kt b/data/src/commonMain/kotlin/ca/gosyer/jui/data/catalog/CatalogPreferences.kt index c37d60ee..7311a758 100644 --- a/data/src/commonMain/kotlin/ca/gosyer/jui/data/catalog/CatalogPreferences.kt +++ b/data/src/commonMain/kotlin/ca/gosyer/jui/data/catalog/CatalogPreferences.kt @@ -7,14 +7,13 @@ package ca.gosyer.jui.data.catalog import androidx.compose.ui.text.intl.Locale -import ca.gosyer.jui.core.lang.getDefault import ca.gosyer.jui.core.prefs.Preference import ca.gosyer.jui.core.prefs.PreferenceStore import ca.gosyer.jui.data.library.model.DisplayMode class CatalogPreferences(private val preferenceStore: PreferenceStore) { fun languages(): Preference> { - return preferenceStore.getStringSet("enabled_langs", setOfNotNull("en", Locale.getDefault().language)) + return preferenceStore.getStringSet("enabled_langs", setOfNotNull("en", Locale.current.language)) } fun displayMode(): Preference { diff --git a/data/src/commonMain/kotlin/ca/gosyer/jui/data/extension/ExtensionPreferences.kt b/data/src/commonMain/kotlin/ca/gosyer/jui/data/extension/ExtensionPreferences.kt index 95ae1681..cf1838c5 100644 --- a/data/src/commonMain/kotlin/ca/gosyer/jui/data/extension/ExtensionPreferences.kt +++ b/data/src/commonMain/kotlin/ca/gosyer/jui/data/extension/ExtensionPreferences.kt @@ -7,12 +7,11 @@ package ca.gosyer.jui.data.extension import androidx.compose.ui.text.intl.Locale -import ca.gosyer.jui.core.lang.getDefault import ca.gosyer.jui.core.prefs.Preference import ca.gosyer.jui.core.prefs.PreferenceStore class ExtensionPreferences(private val preferenceStore: PreferenceStore) { fun languages(): Preference> { - return preferenceStore.getStringSet("enabled_langs", setOfNotNull("all", "en", Locale.getDefault().language)) + return preferenceStore.getStringSet("enabled_langs", setOfNotNull("all", "en", Locale.current.language)) } } diff --git a/data/src/jvmMain/kotlin/ca/gosyer/jui/data/base/JvmDateHandler.kt b/data/src/jvmMain/kotlin/ca/gosyer/jui/data/base/JvmDateHandler.kt index 6e29b0b9..f9b0711e 100644 --- a/data/src/jvmMain/kotlin/ca/gosyer/jui/data/base/JvmDateHandler.kt +++ b/data/src/jvmMain/kotlin/ca/gosyer/jui/data/base/JvmDateHandler.kt @@ -7,7 +7,6 @@ package ca.gosyer.jui.data.base import androidx.compose.ui.text.intl.Locale -import ca.gosyer.jui.core.lang.getDefault import ca.gosyer.jui.core.lang.toPlatform import kotlinx.datetime.Instant import kotlinx.datetime.toJavaInstant @@ -28,7 +27,7 @@ actual class DateHandler @Inject constructor() { actual fun getDateFormat(format: String): (Instant) -> String = when (format) { "" -> DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT) - .withLocale(Locale.getDefault().toPlatform()) + .withLocale(Locale.current.toPlatform()) .withZone(ZoneId.systemDefault()) else -> DateTimeFormatter.ofPattern(format) .withZone(ZoneId.systemDefault()) @@ -41,7 +40,7 @@ actual class DateHandler @Inject constructor() { actual val dateTimeFormat: (Instant) -> String by lazy { DateTimeFormatter .ofLocalizedDateTime(FormatStyle.SHORT) - .withLocale(Locale.getDefault().toPlatform()) + .withLocale(Locale.current.toPlatform()) .withZone(ZoneId.systemDefault()) .let { formatter -> { diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/base/components/LocaleToString.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/base/components/LocaleToString.kt index dc3a5e0c..f7b44232 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/base/components/LocaleToString.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/base/components/LocaleToString.kt @@ -7,9 +7,8 @@ package ca.gosyer.jui.ui.base.components import androidx.compose.ui.text.intl.Locale -import ca.gosyer.jui.core.lang.getDefault import ca.gosyer.jui.core.lang.getDisplayLanguage fun localeToString(locale: String) = Locale(locale) - .getDisplayLanguage(Locale.getDefault()) + .getDisplayLanguage(Locale.current) .ifBlank { locale.uppercase() } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/extensions/components/ExtensionsScreenContent.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/extensions/components/ExtensionsScreenContent.kt index 9b23982f..5c524529 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/extensions/components/ExtensionsScreenContent.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/extensions/components/ExtensionsScreenContent.kt @@ -47,7 +47,6 @@ import androidx.compose.ui.text.intl.Locale import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import ca.gosyer.jui.core.lang.getDefault import ca.gosyer.jui.core.lang.getDisplayName import ca.gosyer.jui.core.lang.uppercase import ca.gosyer.jui.data.models.Extension @@ -168,7 +167,7 @@ fun ExtensionItem( } Text(title, fontSize = 18.sp, color = MaterialTheme.colors.onBackground) Row { - Text(extension.lang.uppercase(Locale.getDefault()), fontSize = 14.sp, color = MaterialTheme.colors.onBackground) + Text(extension.lang.uppercase(Locale.current), fontSize = 14.sp, color = MaterialTheme.colors.onBackground) if (extension.isNsfw) { Spacer(Modifier.width(4.dp)) Text("18+", fontSize = 14.sp, color = Color.Red) @@ -221,7 +220,7 @@ fun LanguageDialog( ) { title(BuildKonfig.NAME) Box { - val locale = remember { Locale.getDefault() } + val locale = remember { Locale.current } val listState = rememberLazyListState() LazyColumn(Modifier.fillMaxWidth(), listState) { items(availableLangs.toList()) { lang -> diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/library/LibraryScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/library/LibraryScreenViewModel.kt index 296559d5..7111d117 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/library/LibraryScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/library/LibraryScreenViewModel.kt @@ -7,7 +7,6 @@ package ca.gosyer.jui.ui.library import androidx.compose.ui.text.intl.Locale -import ca.gosyer.jui.core.lang.getDefault import ca.gosyer.jui.core.lang.lowercase import ca.gosyer.jui.core.lang.withDefaultContext import ca.gosyer.jui.core.prefs.getAsFlow @@ -170,7 +169,7 @@ class LibraryScreenViewModel @Inject constructor( private fun getComparator(sortMode: Sort, ascending: Boolean): Comparator { val sortFn = when (sortMode) { Sort.ALPHABETICAL -> { - val locale = Locale.getDefault() + val locale = Locale.current val collator = Collator(locale); { a: Manga, b: Manga -> diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsGeneralScreen.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsGeneralScreen.kt index 30ac2368..5e24d4c6 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsGeneralScreen.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsGeneralScreen.kt @@ -20,7 +20,6 @@ import androidx.compose.runtime.produceState import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.intl.Locale -import ca.gosyer.jui.core.lang.getDefault import ca.gosyer.jui.core.lang.getDisplayName import ca.gosyer.jui.core.lang.withIOContext import ca.gosyer.jui.data.base.DateHandler @@ -80,7 +79,7 @@ class SettingsGeneralViewModel @Inject constructor( val dateFormat = uiPreferences.dateFormat().asStateFlow() private val now = Clock.System.now() - private val currentLocale = Locale.getDefault() + private val currentLocale = Locale.current @Composable fun getStartScreenChoices() = mapOf(