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") remove("show_manga_app_shortcuts")
} }
} }
if (preferences.lang().get() in listOf("en-US", "en-GB")) {
preferences.lang().set("en")
}
} }
return true return true
} }

View File

@ -296,7 +296,7 @@ class PreferencesHelper(val context: Context) {
fun downloadNewCategories() = flowPrefs.getStringSet(Keys.downloadNewCategories, emptySet()) 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) fun defaultCategory() = prefs.getInt(Keys.defaultCategory, -1)

View File

@ -159,16 +159,79 @@ class SettingsGeneralController : SettingsController() {
listPreference(activity) { listPreference(activity) {
key = Keys.lang key = Keys.lang
titleRes = R.string.language titleRes = R.string.language
entryValues = listOf( val langs = mutableListOf<Pair<String, String>>()
"", "ar", "bg", "bn", "ca", "cs", "de", "el", "en-US", "en-GB", langs += Pair(
"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" "${context.getString(R.string.system_default)} (${LocaleHelper.getDisplayName("")})"
) )
entries = entryValues.map { value -> // Due to compatibility issues:
val locale = LocaleHelper.getLocaleFromString(value) // - Hebrew: `he` is copied into `iw` at build time
locale?.getDisplayName(locale)?.capitalize(Locale.ROOT) langs += arrayOf(
?: context.getString(R.string.system_default) "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 = "" defaultValue = ""
onChange { newValue -> onChange { newValue ->
@ -180,7 +243,6 @@ class SettingsGeneralController : SettingsController() {
true true
} }
} }
listPreference(activity) { listPreference(activity) {
key = Keys.dateFormat key = Keys.dateFormat
titleRes = R.string.date_format 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. * 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 * The currently applied locale. Used to avoid losing the selected language after a non locale