mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-26 14:36:10 -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.
|
||||
*/
|
||||
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
|
||||
@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[languageCode]?.displayLanguage
|
||||
}
|
||||
else -> {
|
||||
""
|
||||
}
|
||||
languageCode.length == 2 -> LanguageContainer(languageCode).languageName
|
||||
languageCode.length == 3 -> localeMap[languageCode]?.displayLanguage.orEmpty()
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user