0
0
mirror of https://github.com/markusfisch/BinaryEye.git synced 2024-09-20 12:02:17 +02:00

Fix creating Locale from resource format

Locale() requires the country part as secondary argument and
can't use the resource format "lang-country" directly.
This commit is contained in:
Markus Fisch 2021-04-08 20:47:31 +02:00
parent 6347bd568c
commit d890bf28fa
2 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,12 @@ import java.util.*
fun Context.applyLocale(localeName: String) {
if (localeName.isNotEmpty()) {
val locale = Locale(localeName)
val localeParts = localeName.split("-")
val locale = if (localeParts.size == 2) {
Locale(localeParts[0], localeParts[1])
} else {
Locale(localeName)
}
Locale.setDefault(locale)
val conf = resources.configuration
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {

View File

@ -16,7 +16,7 @@
<item>Turkish</item>
<item>Ukrainian</item>
<item>Chinese</item>
<item>Chinese (Simplified Han,China)</item>
<item>Chinese (Simplified Han, China)</item>
<item>Japanese</item>
<item>Czech</item>
</string-array>