File tree Expand file tree Collapse file tree
androidHostTest/kotlin/net/igsoft/polyglot/core
androidMain/kotlin/net/igsoft/polyglot/core
commonMain/kotlin/net/igsoft/polyglot/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ fun calculateVersion(baseVersion: String): String {
3030}
3131
3232group = " net.igsoft.polyglot"
33- version = calculateVersion(" 0.3.0 " )
33+ version = calculateVersion(" 0.3.1 " )
3434
3535println (" Version: $version " )
3636
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ kotlin {
1111 namespace = " net.igsoft.polyglot.core"
1212 compileSdk = 37
1313 minSdk = 23
14+ withHostTest {}
1415 compilerOptions {
1516 jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget .JVM_17 )
1617 }
Original file line number Diff line number Diff line change 1+ package net.igsoft.polyglot.core
2+
3+ import java.util.Locale
4+ import kotlin.test.Test
5+ import kotlin.test.assertEquals
6+
7+ class MsgLocaleAndroidTest {
8+
9+ @Test
10+ fun `Given French locale when converting to message locale then preserve language tag` () {
11+ assertEquals(MsgLocale .of(" fr-FR" ), Locale .forLanguageTag(" fr-FR" ).toMsgLocale())
12+ }
13+
14+ @Test
15+ fun `Given French message locale when converting to Java locale then preserve language tag` () {
16+ assertEquals(Locale .forLanguageTag(" fr-FR" ), MsgLocale .of(" fr-FR" ).toJavaLocale())
17+ }
18+
19+ @Test
20+ fun `Given German locale when creating message locale then preserve language tag` () {
21+ assertEquals(MsgLocale .of(" de" ), MsgLocale .of(Locale .GERMAN ))
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ package net.igsoft.polyglot.core
2+
3+ import java.util.Locale
4+
5+ fun MsgLocale.Companion.of (locale : Locale ): MsgLocale = MsgLocale .of(locale.toLanguageTag())
6+
7+ fun Locale.toMsgLocale (): MsgLocale = MsgLocale .of(this )
8+
9+ fun MsgLocale.toJavaLocale (): Locale = Locale .forLanguageTag(languageTag)
Original file line number Diff line number Diff line change @@ -12,4 +12,9 @@ object MsgLocales {
1212
1313 val PL_PL : MsgLocale
1414 get() = MsgLocale .of(" pl-PL" )
15+
16+ val DE get() = MsgLocale .of(" de" )
17+ val ES get() = MsgLocale .of(" es" )
18+ val FR get() = MsgLocale .of(" fr" )
19+ val IT get() = MsgLocale .of(" it" )
1520}
You can’t perform that action at this time.
0 commit comments