fix(resources): update locale provider to include pt-rBR instead of pt-rPT

This commit is contained in:
Akash Yadav
2024-01-18 20:50:09 +05:30
parent a96833758f
commit b913f3cd65
3 changed files with 13 additions and 5 deletions
@@ -58,7 +58,6 @@ import com.itsaky.androidide.tasks.executeAsync
import com.itsaky.androidide.treesitter.TreeSitter
import com.itsaky.androidide.ui.themes.IDETheme
import com.itsaky.androidide.ui.themes.IThemeManager
import com.itsaky.androidide.ui.themes.ThemeManager
import com.itsaky.androidide.utils.ILogger
import com.itsaky.androidide.utils.RecyclableObjectPool
import com.itsaky.androidide.utils.VMUtils
@@ -70,7 +69,6 @@ import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import java.lang.Thread.UncaughtExceptionHandler
import java.time.Duration
import java.util.Locale
import kotlin.system.exitProcess
class IDEApplication : TermuxApplication() {
@@ -18,6 +18,7 @@
package com.itsaky.androidide.preferences.internal
import androidx.appcompat.app.AppCompatDelegate
import com.itsaky.androidide.resources.localization.LocaleProvider
const val IS_FIRST_PROJECT_BUILD = "project_isFirstBuild"
const val UI_MODE = "idepref_general_uiMode"
@@ -43,7 +44,16 @@ var selectedTheme: String?
}
var selectedLocale: String?
get() = prefManager.getString(SELECTED_LOCALE, null)
get() = prefManager.getString(SELECTED_LOCALE, null).let { locale ->
// if the locale is set to a locale key that is not supported,
// fall back to 'System default'
if (LocaleProvider.getLocale(locale) == null) {
null
} else {
locale
}
}
set(value) {
prefManager.putString(SELECTED_LOCALE, value)
}
@@ -46,7 +46,7 @@ public class LocaleProvider {
putLocale(locales, keys, "fr", "FR"); // French
putLocale(locales, keys, "hi", "IN"); // Hindi
putLocale(locales, keys, "in", "ID"); // Indonesian
putLocale(locales, keys, "pt", "PT"); // Portuguese
putLocale(locales, keys, "pt", "BR"); // Portuguese, Brazilian
putLocale(locales, keys, "ro", "RO"); // Romanian
putLocale(locales, keys, "ru", "RU"); // Russian
putLocale(locales, keys, "tr", "TR"); // Turkish
@@ -57,7 +57,7 @@ public class LocaleProvider {
}
@Nullable
public static Locale getLocale(String key) {
public static Locale getLocale(@Nullable String key) {
if (key == null || StringsKt.isBlank(key)) {
return null;
}