Closes #18386 - Change language display name to traditional/simplified Chinese for Chinese locale (#18387)

upstream-sync
rxumoz 3 years ago committed by GitHub
parent ccfb275b03
commit 51c41f84d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,10 +23,14 @@ class LocaleViewHolder(
if (locale.toString().equals("vec", ignoreCase = true)) {
locale.toString()
}
// Capitalisation is done using the rules of the appropriate locale (endonym and exonym).
locale_title_text.text = getDisplayName(locale)
// Show the given locale using the device locale for the subtitle.
locale_subtitle_text.text = locale.getProperDisplayName()
if (locale.language == "zh") {
bindChineseLocale(locale)
} else {
// Capitalisation is done using the rules of the appropriate locale (endonym and exonym).
locale_title_text.text = getDisplayName(locale)
// Show the given locale using the device locale for the subtitle.
locale_subtitle_text.text = locale.getProperDisplayName()
}
locale_selected_icon.isVisible = isCurrentLocaleSelected(locale, isDefault = false)
itemView.setOnClickListener {
@ -34,6 +38,20 @@ class LocaleViewHolder(
}
}
private fun bindChineseLocale(locale: Locale) {
if (locale.country == "CN") {
locale_title_text.text =
Locale.forLanguageTag("zh-Hans").getDisplayName(locale).capitalize(locale)
locale_subtitle_text.text =
Locale.forLanguageTag("zh-Hans").displayName.capitalize(Locale.getDefault())
} else if (locale.country == "TW") {
locale_title_text.text =
Locale.forLanguageTag("zh-Hant").getDisplayName(locale).capitalize(locale)
locale_subtitle_text.text =
Locale.forLanguageTag("zh-Hant").displayName.capitalize(Locale.getDefault())
}
}
private fun getDisplayName(locale: Locale): String {
val displayName = locale.getDisplayName(locale).capitalize(locale)
if (displayName.equals(locale.toString(), ignoreCase = true)) {
@ -255,8 +273,16 @@ class SystemLocaleViewHolder(
override fun bind(locale: Locale) {
locale_title_text.text = itemView.context.getString(R.string.default_locale_text)
// Use the device locale for the system locale subtitle.
locale_subtitle_text.text = locale.getDisplayName(locale).capitalize(locale)
if (locale.script == "Hant") {
locale_subtitle_text.text =
Locale.forLanguageTag("zh-Hant").displayName.capitalize(Locale.getDefault())
} else if (locale.script == "Hans") {
locale_subtitle_text.text =
Locale.forLanguageTag("zh-Hans").displayName.capitalize(Locale.getDefault())
} else {
// Use the device locale for the system locale subtitle.
locale_subtitle_text.text = locale.getDisplayName(locale).capitalize(locale)
}
locale_selected_icon.isVisible = isCurrentLocaleSelected(locale, isDefault = true)
itemView.setOnClickListener {
interactor.onDefaultLocaleSelected()

Loading…
Cancel
Save