LocaleHelper: use argument for a when expression (#8131)

This commit is contained in:
stevenyomi 2022-10-02 22:08:12 +08:00 committed by GitHub
parent e24501da09
commit ff4fb83bff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,10 +34,10 @@ object LocaleHelper {
return ""
}
val locale = when {
lang.isEmpty() -> LocaleListCompat.getAdjustedDefault()[0]
lang == "zh-CN" -> Locale.forLanguageTag("zh-Hans")
lang == "zh-TW" -> Locale.forLanguageTag("zh-Hant")
val locale = when (lang) {
"" -> LocaleListCompat.getAdjustedDefault()[0]
"zh-CN" -> Locale.forLanguageTag("zh-Hans")
"zh-TW" -> Locale.forLanguageTag("zh-Hant")
else -> Locale.forLanguageTag(lang)
}
return locale!!.getDisplayName(locale).replaceFirstChar { it.uppercase(locale) }