Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Version used: 1.13.0-alpha05
Devices/Android versions reproduced on:
zh-rCN and zh-rTW not available using LocaleListCompat
using this code chineese locales not appeared in the list, also in system settings on android 13+ zh locales not visible to select
private fun Context.getLanguages(): Map<String, String> {
val languages = mutableListOf("" to getString(R.string.system))
val parser = resources.getXml(R.xml.locales_config)
var eventType = parser.eventType
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG &&
for (i in 0 until parser.attributeCount) {
if (parser.getAttributeName(i) == "name") {
val langTag = parser.getAttributeValue(i)
val displayName = getDisplayName(langTag)
if (displayName.isNotEmpty()) {
languages.add(Pair(langTag, displayName))
}
}
}
}
eventType = parser.next()
}
return languages.let { tags ->
listOf(tags.first()) + tags.drop(1).sortedBy { it.second }
}.toMap()
}
private fun Context.getCurrentLocaleString(): String {
val locales = AppCompatDelegate.getApplicationLocales()
if (locales == LocaleListCompat.getEmptyLocaleList()) {
return getString(R.string.system)
}
return getDisplayName(locales.toLanguageTags())
}
private fun getDisplayName(lang: String?): String {
if (lang == null) {
return ""
}
val locale = when (lang) {
"" -> LocaleListCompat.getAdjustedDefault()[0]
else -> Locale.forLanguageTag(lang)
}
return locale!!.getDisplayName(locale).replaceFirstChar { it.uppercase(locale) }
}