diff --git a/build.gradle b/build.gradle index 4a44bcd..f245664 100644 --- a/build.gradle +++ b/build.gradle @@ -84,6 +84,9 @@ kotlin { } sourceSets["iosSimulatorArm64Main"].dependsOn(sourceSets["iosMain"]) + + // TODO: Remove as soon as Android Studio (Iguana) is fixed + task("testClasses") } android { diff --git a/gradle.properties b/gradle.properties index 278eac3..f3fb4e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 systemProp.org.gradle.internal.publish.checksums.insecure=true # -------dependency versions------- # shared -versions_kotlin=1.9.22 +versions_kotlin=1.9.23 versions_linter=12.1.0 versions_coroutines=1.7.3 datetime_version=0.5.0 diff --git a/src/androidMain/kotlin/ch/dreipol/dreimultiplatform/Localize.kt b/src/androidMain/kotlin/ch/dreipol/dreimultiplatform/Localize.kt index 1072f35..df55c77 100644 --- a/src/androidMain/kotlin/ch/dreipol/dreimultiplatform/Localize.kt +++ b/src/androidMain/kotlin/ch/dreipol/dreimultiplatform/Localize.kt @@ -3,12 +3,21 @@ package ch.dreipol.dreimultiplatform import android.content.Context fun Context.getString(identifier: String): String { - val resourceId = resources.getIdentifier(identifier, "string", packageName) + val resourceId = stringId(identifier) return resources.getString(resourceId) } +private fun Context.stringId(identifier: String): Int { + return resources.getIdentifier(identifier, "string", packageName) +} + +fun Context.getString(identifier: String, vararg args: Any): String { + val stringId = stringId(identifier) + return resources.getString(stringId, *args) +} + class Localizer(private val context: Context) : Localize { - override fun localize(string: String): String { - return context.getString(string) - } + override fun localize(string: String): String = context.getString(string) + + override fun localize(string: String, vararg args: Any): String = context.getString(string, *args) } \ No newline at end of file diff --git a/src/commonMain/kotlin/ch/dreipol/dreimultiplatform/Localize.kt b/src/commonMain/kotlin/ch/dreipol/dreimultiplatform/Localize.kt index ba0744c..325d9b9 100644 --- a/src/commonMain/kotlin/ch/dreipol/dreimultiplatform/Localize.kt +++ b/src/commonMain/kotlin/ch/dreipol/dreimultiplatform/Localize.kt @@ -2,4 +2,6 @@ package ch.dreipol.dreimultiplatform interface Localize { fun localize(string: String): String + fun localize(string: String, vararg args: Any): String + } \ No newline at end of file