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 "" return ""
} }
val locale = when { val locale = when (lang) {
lang.isEmpty() -> LocaleListCompat.getAdjustedDefault()[0] "" -> LocaleListCompat.getAdjustedDefault()[0]
lang == "zh-CN" -> Locale.forLanguageTag("zh-Hans") "zh-CN" -> Locale.forLanguageTag("zh-Hans")
lang == "zh-TW" -> Locale.forLanguageTag("zh-Hant") "zh-TW" -> Locale.forLanguageTag("zh-Hant")
else -> Locale.forLanguageTag(lang) else -> Locale.forLanguageTag(lang)
} }
return locale!!.getDisplayName(locale).replaceFirstChar { it.uppercase(locale) } return locale!!.getDisplayName(locale).replaceFirstChar { it.uppercase(locale) }