mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Use CommonMain for presentation, use Klock date/format library
This commit is contained in:
@@ -48,6 +48,7 @@ kotlin {
|
||||
api(libs.multiplatformSettings.coroutines)
|
||||
api(libs.multiplatformSettings.serialization)
|
||||
api(libs.locale)
|
||||
api(libs.klock)
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
|
||||
@@ -8,4 +8,5 @@ package ca.gosyer.core.io
|
||||
|
||||
import okio.FileSystem
|
||||
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
expect val FileSystem.Companion.SYSTEM: FileSystem
|
||||
|
||||
@@ -9,4 +9,5 @@ package ca.gosyer.core.lang
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
expect val Dispatchers.IO: CoroutineDispatcher
|
||||
|
||||
@@ -9,3 +9,9 @@ package ca.gosyer.core.lang
|
||||
import io.fluidsonic.locale.Locale
|
||||
|
||||
expect fun Locale.Companion.getDefault(): Locale
|
||||
|
||||
expect fun Locale.getDisplayLanguage(displayLocale: Locale): String
|
||||
|
||||
expect fun Locale.getDisplayName(displayLocale: Locale): String
|
||||
|
||||
expect val Locale.displayName: String
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
package ca.gosyer.core.lang
|
||||
|
||||
import io.fluidsonic.locale.Locale
|
||||
|
||||
/**
|
||||
* Replaces the given string to have at most [count] characters using [replacement] at its end.
|
||||
* If [replacement] is longer than [count] an exception will be thrown when `length > count`.
|
||||
@@ -17,3 +19,9 @@ fun String.chop(count: Int, replacement: String = "…"): String {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
expect fun String.uppercase(locale: Locale): String
|
||||
|
||||
expect fun String.lowercase(locale: Locale): String
|
||||
|
||||
expect fun Char.titlecase(locale: Locale): String
|
||||
@@ -8,6 +8,15 @@ package ca.gosyer.core.lang
|
||||
|
||||
import io.fluidsonic.locale.Locale
|
||||
import io.fluidsonic.locale.toCommon
|
||||
import io.fluidsonic.locale.toPlatform
|
||||
import java.util.Locale as PlatformLocale
|
||||
|
||||
actual fun Locale.Companion.getDefault(): Locale = PlatformLocale.getDefault().toCommon()
|
||||
|
||||
actual fun Locale.getDisplayLanguage(displayLocale: Locale): String = toPlatform()
|
||||
.getDisplayLanguage(displayLocale.toPlatform())
|
||||
|
||||
actual fun Locale.getDisplayName(displayLocale: Locale): String = toPlatform()
|
||||
.getDisplayName(displayLocale.toPlatform())
|
||||
|
||||
actual val Locale.displayName get() = toPlatform().displayName
|
||||
@@ -7,7 +7,15 @@
|
||||
|
||||
package ca.gosyer.core.lang
|
||||
|
||||
import java.util.Locale
|
||||
import io.fluidsonic.locale.Locale
|
||||
import io.fluidsonic.locale.toPlatform
|
||||
|
||||
fun String.capitalize(locale: Locale = Locale.getDefault()) =
|
||||
replaceFirstChar { if (it.isLowerCase()) it.titlecase(locale) else it.toString() }
|
||||
|
||||
|
||||
actual fun String.uppercase(locale: Locale): String = uppercase(locale.toPlatform())
|
||||
|
||||
actual fun String.lowercase(locale: Locale): String = lowercase(locale.toPlatform())
|
||||
|
||||
actual fun Char.titlecase(locale: Locale): String = titlecase(locale.toPlatform())
|
||||
Reference in New Issue
Block a user