From b7f5ed751df9917639a99c1da6ded6b0c4a5081b Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 2 Jul 2021 09:02:28 -0400 Subject: [PATCH] Remove en-GB option since we don't actually localize different English locales --- .../java/eu/kanade/tachiyomi/Migrations.kt | 3 + .../data/preference/PreferencesHelper.kt | 2 +- .../ui/setting/SettingsGeneralController.kt | 82 ++++++++++++++++--- .../tachiyomi/util/system/LocaleHelper.kt | 2 +- 4 files changed, 77 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index 2d73d04578..2d1af7f2c2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -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 } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index f47c93f092..7e5ba3054f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index 29337d717b..df109b32db 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -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>() + 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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt index 37e7af64d2..50d4d902fd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt @@ -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