Skip to content

Commit

Permalink
icerockdev#329 review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex009 committed Mar 24, 2023
1 parent a3d7332 commit 260798d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

@file:JvmName("StringDescJvm")

package dev.icerock.moko.resources.desc

import android.content.Context
Expand All @@ -22,20 +20,28 @@ actual interface StringDesc {
actual class Custom actual constructor(
private val locale: String
) : LocaleType() {
override val systemLocale: Locale get() {
val languageTagParts = locale.split("-")
return when (languageTagParts.size) {
LANGUAGE -> Locale(languageTagParts[0])
LANGUAGE_AND_COUNTRY -> Locale(languageTagParts[0], languageTagParts[1])
LANGUAGE_AND_COUNTRY_AND_VARIANT -> Locale(
languageTagParts[0],
languageTagParts[1],
languageTagParts[2]
)
else -> throw IllegalArgumentException(
"Invalid language tag $locale which has more than three parts."
)
override val systemLocale: Locale
get() {
val languageTagParts: List<String> = locale.split("-")
return when (languageTagParts.size) {
LANGUAGE -> Locale(languageTagParts[0])
LANGUAGE_AND_COUNTRY -> Locale(languageTagParts[0], languageTagParts[1])
LANGUAGE_AND_COUNTRY_AND_VARIANT -> Locale(
languageTagParts[0],
languageTagParts[1],
languageTagParts[2]
)

else -> throw IllegalArgumentException(
"Invalid language tag $locale which has more than three parts."
)
}
}

private companion object {
private const val LANGUAGE = 1
private const val LANGUAGE_AND_COUNTRY = 2
private const val LANGUAGE_AND_COUNTRY_AND_VARIANT = 3
}
}
}
Expand All @@ -44,7 +50,3 @@ actual interface StringDesc {
actual var localeType: LocaleType = LocaleType.System
}
}

private const val LANGUAGE = 1
private const val LANGUAGE_AND_COUNTRY = 2
private const val LANGUAGE_AND_COUNTRY_AND_VARIANT = 3
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
<string name="multilined">первая строка\nвторая строка\nтретья строка.</string>
<string name="quotes">Alex009 сказал "привет мир" &amp; "пишите тесты".</string>
<string name="single_quotes">Alex009 сказал \'привет\'</string>
<string name="test.dialect">Spanish</string>
<string name="test.dialect">Russian</string>
</resources>

0 comments on commit 260798d

Please sign in to comment.