From 9ccf951b8ce61c02f9c90a69b24af89571cfbddc Mon Sep 17 00:00:00 2001 From: "thomas.JY.Lin@gmail.com" Date: Sun, 13 Nov 2022 07:51:00 +0800 Subject: [PATCH] appLanguageExceptions --- .../com/lagradost/cloudstream3/CommonActivity.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt index 47a195d1..402866d8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt @@ -107,10 +107,19 @@ object CommonActivity { logError(e) } } + + /** + * Not all languages can be fetched from locale with a code. + * This map allows sidestepping the default Locale(languageCode) + * when setting the app language. + **/ + val appLanguageExceptions = hashMapOf( + "zh-TW" to Locale.TRADITIONAL_CHINESE + ) fun setLocale(context: Context?, languageCode: String?) { if (context == null || languageCode == null) return - val locale = Locale(languageCode) + val locale = appLanguageExceptions[languageCode] ?: Locale(languageCode) val resources: Resources = context.resources val config = resources.configuration Locale.setDefault(locale) @@ -421,4 +430,4 @@ object CommonActivity { } return null } -} \ No newline at end of file +}