mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-27 23:20:58 -04:00
Removing multiple locale object and cleaning code
This commit is contained in:
parent
2b07462ae1
commit
e108d04903
@ -23,22 +23,16 @@ 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)
|
val localeMap = Locale.getISOLanguages().map(::Locale).associateBy { it.isO3Language }
|
||||||
|
|
||||||
// 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 -> localeMap[languageCode]?.displayLanguage.orEmpty()
|
||||||
}
|
else -> ""
|
||||||
languageCode.length == 3 -> {
|
|
||||||
localeMap[languageCode]?.displayLanguage
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user