mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-13 09:26:52 -04:00
Fixing BookUtil error
This commit is contained in:
parent
91fc864d9f
commit
41b7abf565
@ -45,7 +45,7 @@ fun Book.buildSearchableText(bookUtils: BookUtils): String =
|
||||
append(NetworkUtils.parseURL(CoreApp.getInstance(), url))
|
||||
append("|")
|
||||
if (bookUtils.localeMap.containsKey(language)) {
|
||||
append(bookUtils.localeMap[language]!!.displayLanguage)
|
||||
append(bookUtils.localeMap[language]?.displayLanguage)
|
||||
append("|")
|
||||
}
|
||||
}.toString()
|
||||
|
@ -17,25 +17,24 @@
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.core.utils
|
||||
|
||||
import java.util.HashMap
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Created by mhutti1 on 19/04/17.
|
||||
*/
|
||||
class BookUtils {
|
||||
val localeMap = Locale.getISOLanguages().associateBy { Locale(it).isO3Language; Locale(it) }
|
||||
val localeMap = Locale.getISOLanguages().associateBy({ Locale(it).isO3Language }, ::Locale)
|
||||
|
||||
// Get the language from the language codes of the parsed xml stream
|
||||
@Suppress("MagicNumber")
|
||||
fun getLanguage(languageCode: String?): String {
|
||||
fun getLanguage(languageCode: String): String? {
|
||||
return when {
|
||||
languageCode == null -> ""
|
||||
languageCode.length == 2 -> {
|
||||
LanguageContainer(languageCode).languageName
|
||||
}
|
||||
languageCode.length == 3 -> {
|
||||
localeMap.filter { it.value == languageCode }.keys.first().displayLanguage
|
||||
localeMap[languageCode]?.displayLanguage
|
||||
}
|
||||
else -> {
|
||||
""
|
||||
@ -43,4 +42,4 @@ class BookUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user