From 3291538446b7fccec46fa52775e6bf594c77b9f4 Mon Sep 17 00:00:00 2001 From: weishu Date: Thu, 21 Mar 2024 14:45:25 +0800 Subject: [PATCH] manager: allow to query language if country is unknown. close #1495 --- .../me/weishu/kernelsu/ui/viewmodel/TemplateViewModel.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/TemplateViewModel.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/TemplateViewModel.kt index 2ccfa147c12d..c5564a8f9cbb 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/TemplateViewModel.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/TemplateViewModel.kt @@ -209,9 +209,14 @@ private fun getLocaleString(json: JSONObject, key: String): String { val locale = Locale.getDefault() val localeKey = "${locale.language}_${locale.country}" json.optJSONObject("locales")?.let { + // check locale first it.optJSONObject(localeKey)?.let { json-> return json.optString(key, fallback) } + // fallback to language + it.optJSONObject(locale.language)?.let { json-> + return json.optString(key, fallback) + } } return fallback }