mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
appLanguageExceptions
This commit is contained in:
parent
3fc63a2165
commit
9ccf951b8c
1 changed files with 11 additions and 2 deletions
|
@ -107,10 +107,19 @@ object CommonActivity {
|
||||||
logError(e)
|
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?) {
|
fun setLocale(context: Context?, languageCode: String?) {
|
||||||
if (context == null || languageCode == null) return
|
if (context == null || languageCode == null) return
|
||||||
val locale = Locale(languageCode)
|
val locale = appLanguageExceptions[languageCode] ?: Locale(languageCode)
|
||||||
val resources: Resources = context.resources
|
val resources: Resources = context.resources
|
||||||
val config = resources.configuration
|
val config = resources.configuration
|
||||||
Locale.setDefault(locale)
|
Locale.setDefault(locale)
|
||||||
|
@ -421,4 +430,4 @@ object CommonActivity {
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue