Skip to content

Commit

Permalink
Updated getLocale function to use appropriate Locale constants (#3413)
Browse files Browse the repository at this point in the history
Updated getLocale function to use appropriate Locale constants
  • Loading branch information
CodeWithTamim authored Aug 3, 2024
1 parent 1ac19ae commit a1455bb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -403,18 +403,21 @@ object Utils {
}
}

fun getLocale(): Locale =
when (settingsStorage?.decodeString(AppConfig.PREF_LANGUAGE) ?: "auto") {
"auto" -> getSysLocale()
"en" -> Locale("en")
"zh-rCN" -> Locale("zh", "CN")
"zh-rTW" -> Locale("zh", "TW")
fun getLocale(): Locale {
val lang = settingsStorage?.decodeString(AppConfig.PREF_LANGUAGE) ?: "auto"
return when (lang) {
"auto" -> getSysLocale()
"en" -> Locale.ENGLISH
"zh-rCN" -> Locale.CHINA
"zh-rTW" -> Locale.TRADITIONAL_CHINESE
"vi" -> Locale("vi")
"ru" -> Locale("ru")
"fa" -> Locale("fa")
"bn" -> Locale("bn")
else -> getSysLocale()
}
}


private fun getSysLocale(): Locale = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
LocaleList.getDefault()[0]
Expand Down

0 comments on commit a1455bb

Please sign in to comment.