Remove en-GB option since we don't actually localize different English locales

This commit is contained in:
arkon 2021-07-02 09:02:28 -04:00 committed by Jays2Kings
parent 84d73fd910
commit b7f5ed751d
4 changed files with 77 additions and 12 deletions

View File

@ -131,6 +131,9 @@ object Migrations {
remove("show_manga_app_shortcuts")
}
}
if (preferences.lang().get() in listOf("en-US", "en-GB")) {
preferences.lang().set("en")
}
}
return true
}

View File

@ -296,7 +296,7 @@ class PreferencesHelper(val context: Context) {
fun downloadNewCategories() = flowPrefs.getStringSet(Keys.downloadNewCategories, emptySet())
fun lang() = prefs.getString(Keys.lang, "")
fun lang() = flowPrefs.getString(Keys.lang, "")
fun defaultCategory() = prefs.getInt(Keys.defaultCategory, -1)

View File

@ -159,16 +159,79 @@ class SettingsGeneralController : SettingsController() {
listPreference(activity) {
key = Keys.lang
titleRes = R.string.language
entryValues = listOf(
"", "ar", "bg", "bn", "ca", "cs", "de", "el", "en-US", "en-GB",
"es", "fr", "hi", "hu", "in", "it", "ja", "ko", "lv", "ms", "nb-rNO", "nl", "pl", "pt",
"pt-BR", "ro", "ru", "sc", "sr", "sv", "th", "tl", "tr", "uk", "vi", "zh-rCN"
val langs = mutableListOf<Pair<String, String>>()
langs += Pair(
"",
"${context.getString(R.string.system_default)} (${LocaleHelper.getDisplayName("")})"
)
entries = entryValues.map { value ->
val locale = LocaleHelper.getLocaleFromString(value)
locale?.getDisplayName(locale)?.capitalize(Locale.ROOT)
?: context.getString(R.string.system_default)
// Due to compatibility issues:
// - Hebrew: `he` is copied into `iw` at build time
langs += arrayOf(
"am",
"ar",
"be",
"bg",
"bn",
"ca",
"cs",
"cv",
"de",
"el",
"eo",
"es",
"es-419",
"en",
"fa",
"fi",
"fil",
"fr",
"gl",
"he",
"hi",
"hr",
"hu",
"in",
"it",
"ja",
"jv",
"ka-rGE",
"kn",
"ko",
"lt",
"lv",
"mr",
"ms",
"my",
"nb-rNO",
"ne",
"nl",
"pl",
"pt",
"pt-BR",
"ro",
"ru",
"sah",
"sc",
"sk",
"sr",
"sv",
"te",
"th",
"tr",
"uk",
"ur-rPK",
"vi",
"uz",
"zh-rCN",
"zh-rTW"
)
.map {
Pair(it, LocaleHelper.getDisplayName(it))
}
.sortedBy { it.second }
entryValues = langs.map { it.first }
entries = langs.map { it.second }
defaultValue = ""
onChange { newValue ->
@ -180,7 +243,6 @@ class SettingsGeneralController : SettingsController() {
true
}
}
listPreference(activity) {
key = Keys.dateFormat
titleRes = R.string.date_format

View File

@ -30,7 +30,7 @@ object LocaleHelper {
/**
* The application's locale. When it's null, the system locale is used.
*/
private var appLocale = getLocaleFromString(preferences.lang() ?: "")
private var appLocale = getLocaleFromString(preferences.lang().get())
/**
* The currently applied locale. Used to avoid losing the selected language after a non locale