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(NetworkUtils.parseURL(CoreApp.getInstance(), url))
|
||||||
append("|")
|
append("|")
|
||||||
if (bookUtils.localeMap.containsKey(language)) {
|
if (bookUtils.localeMap.containsKey(language)) {
|
||||||
append(bookUtils.localeMap[language]!!.displayLanguage)
|
append(bookUtils.localeMap[language]?.displayLanguage)
|
||||||
append("|")
|
append("|")
|
||||||
}
|
}
|
||||||
}.toString()
|
}.toString()
|
||||||
|
@ -17,25 +17,24 @@
|
|||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.core.utils
|
package org.kiwix.kiwixmobile.core.utils
|
||||||
|
|
||||||
import java.util.HashMap
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mhutti1 on 19/04/17.
|
* Created by mhutti1 on 19/04/17.
|
||||||
*/
|
*/
|
||||||
class BookUtils {
|
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
|
// Get the language from the language codes of the parsed xml stream
|
||||||
@Suppress("MagicNumber")
|
@Suppress("MagicNumber")
|
||||||
fun getLanguage(languageCode: String?): String {
|
fun getLanguage(languageCode: String): String? {
|
||||||
return when {
|
return when {
|
||||||
languageCode == null -> ""
|
languageCode == null -> ""
|
||||||
languageCode.length == 2 -> {
|
languageCode.length == 2 -> {
|
||||||
LanguageContainer(languageCode).languageName
|
LanguageContainer(languageCode).languageName
|
||||||
}
|
}
|
||||||
languageCode.length == 3 -> {
|
languageCode.length == 3 -> {
|
||||||
localeMap.filter { it.value == languageCode }.keys.first().displayLanguage
|
localeMap[languageCode]?.displayLanguage
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
""
|
""
|
||||||
@ -43,4 +42,4 @@ class BookUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user