Fix the Luri locale

This commit is contained in:
EmmanuelMess
2026-04-17 16:36:06 -03:00
parent 2d0587f54d
commit e6b9adac3f
4 changed files with 30 additions and 41 deletions
@@ -67,51 +67,39 @@ fun Context.getLocaleListFromXml(): LocaleListCompat {
* For preference drop down convenience.
*/
fun Context.getLangPreferenceDropdownEntries(): Map<String, Locale> {
val localeList = getLocaleListFromXml()
val currentLocaleList: List<Locale> =
(
if (!AppCompatDelegate.getApplicationLocales().isEmpty) {
AppCompatDelegate.getApplicationLocales()
} else {
LocaleListCompat.getDefault()
}
).let { appLocales ->
ArrayList<Locale>().apply {
for (x in 0 until appLocales.size()) {
appLocales.get(x)?.let {
this.add(it)
}
}
}
val appLocales =
if (AppCompatDelegate.getApplicationLocales().isEmpty) {
LocaleListCompat.getDefault()
} else {
AppCompatDelegate.getApplicationLocales()
}
val currentLocaleList = ArrayList<Locale>()
for (i in 0 until appLocales.size()) {
val appLocale = appLocales.get(i) ?: continue
currentLocaleList.add(appLocale)
}
val xmlLocales = getLocaleListFromXml()
val map = mutableMapOf<String, Locale>()
for (a in 0 until localeList.size()) {
localeList[a].let {
it?.run {
val displayName: String =
if (currentLocaleList.isEmpty()) {
this.getDisplayName(Locale.getDefault())
} else {
this.getDisplayName(
currentLocaleList.first { locale ->
this.getDisplayName(locale).isNotEmpty()
},
)
for (i in 0 until xmlLocales.size()) {
val xmlLocale = xmlLocales[i] ?: continue
val displayName: String =
if (currentLocaleList.isEmpty()) {
xmlLocale.getDisplayName(Locale.getDefault())
} else {
val nameInCurrentLocale =
currentLocaleList.first { locale ->
xmlLocale.getDisplayName(locale).isNotEmpty()
}
map.put(displayName, this)
xmlLocale.getDisplayName(nameInCurrentLocale)
}
}
map[displayName] = xmlLocale
}
return map
}
/**
* [Context] extension to set app locale fluently.
*
* Calls [AppCompatDelegate.setApplicationLocales] under the hood.
*/
fun Context.setLocale(langTag: String) {
val appLocale: LocaleListCompat = LocaleListCompat.forLanguageTags(langTag)
AppCompatDelegate.setApplicationLocales(appLocale)
}
+1 -1
View File
@@ -10,7 +10,7 @@
<locale android:name="bg" />
<locale android:name="bn" />
<locale android:name="bn-BD" />
<locale android:name="bqi-LU" />
<locale android:name="bqi-IR" />
<locale android:name="br-FR" />
<locale android:name="bs-BA" />
<locale android:name="ca" />
+1
View File
@@ -48,6 +48,7 @@ settings:
en_IN: en-IN
es_ES: es-rES
es_VE: es-rVE
bqi: bqi-rIR
ms_MY: ms-rMY
bg_BG: bg-rBG
hu: hu-rHU