From 36f307e3bbf5a52277fba3033a08201cd37f779a Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 6 Jan 2024 18:14:45 -0500 Subject: [PATCH] Normalize some locale names --- .../presentation/browse/GlobalSearchScreen.kt | 2 +- .../screen/appearance/AppLanguageScreen.kt | 5 ++--- .../kanade/tachiyomi/util/system/LocaleHelper.kt | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt index b067968486..7f79dd3ed1 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt @@ -77,7 +77,7 @@ internal fun GlobalSearchContent( title = fromSourceId?.let { "▶ ${source.name}".takeIf { source.id == fromSourceId } } ?: source.name, - subtitle = LocaleHelper.getDisplayName(source.lang), + subtitle = LocaleHelper.getLocalizedDisplayName(source.lang), onClick = { onClickSource(source) }, ) { when (result) { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/appearance/AppLanguageScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/appearance/AppLanguageScreen.kt index 8fc49cf401..bdba9e15ce 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/appearance/AppLanguageScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/appearance/AppLanguageScreen.kt @@ -34,7 +34,6 @@ import tachiyomi.core.i18n.stringResource import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.i18n.stringResource -import java.util.Locale class AppLanguageScreen : Screen() { @@ -104,9 +103,9 @@ class AppLanguageScreen : Screen() { for (i in 0.. context.stringResource(MR.strings.pinned_sources) "other" -> context.stringResource(MR.strings.other_source) "all" -> context.stringResource(MR.strings.multi_lang) - else -> getDisplayName(lang) + else -> getLocalizedDisplayName(lang) } } + fun getDisplayName(lang: String): String { + val normalizedLang = when (lang) { + "zh-CN" -> "zh-Hans" + "zh-TW" -> "zh-Hant" + else -> lang + } + + return Locale.forLanguageTag(normalizedLang).displayName + } + /** * Returns display name of a string language code. * * @param lang empty for system language */ - fun getDisplayName(lang: String?): String { + fun getLocalizedDisplayName(lang: String?): String { if (lang == null) { return "" }