Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit b913f3c

Browse files
committed
fix(resources): update locale provider to include pt-rBR instead of pt-rPT
1 parent a968337 commit b913f3c

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

app/src/main/java/com/itsaky/androidide/app/IDEApplication.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import com.itsaky.androidide.tasks.executeAsync
5858
import com.itsaky.androidide.treesitter.TreeSitter
5959
import com.itsaky.androidide.ui.themes.IDETheme
6060
import com.itsaky.androidide.ui.themes.IThemeManager
61-
import com.itsaky.androidide.ui.themes.ThemeManager
6261
import com.itsaky.androidide.utils.ILogger
6362
import com.itsaky.androidide.utils.RecyclableObjectPool
6463
import com.itsaky.androidide.utils.VMUtils
@@ -70,7 +69,6 @@ import org.greenrobot.eventbus.Subscribe
7069
import org.greenrobot.eventbus.ThreadMode
7170
import java.lang.Thread.UncaughtExceptionHandler
7271
import java.time.Duration
73-
import java.util.Locale
7472
import kotlin.system.exitProcess
7573

7674
class IDEApplication : TermuxApplication() {

preferences/src/main/java/com/itsaky/androidide/preferences/internal/generalPreferences.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.itsaky.androidide.preferences.internal
1919

2020
import androidx.appcompat.app.AppCompatDelegate
21+
import com.itsaky.androidide.resources.localization.LocaleProvider
2122

2223
const val IS_FIRST_PROJECT_BUILD = "project_isFirstBuild"
2324
const val UI_MODE = "idepref_general_uiMode"
@@ -43,7 +44,16 @@ var selectedTheme: String?
4344
}
4445

4546
var selectedLocale: String?
46-
get() = prefManager.getString(SELECTED_LOCALE, null)
47+
get() = prefManager.getString(SELECTED_LOCALE, null).let { locale ->
48+
49+
// if the locale is set to a locale key that is not supported,
50+
// fall back to 'System default'
51+
if (LocaleProvider.getLocale(locale) == null) {
52+
null
53+
} else {
54+
locale
55+
}
56+
}
4757
set(value) {
4858
prefManager.putString(SELECTED_LOCALE, value)
4959
}

resources/src/main/java/com/itsaky/androidide/resources/localization/LocaleProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class LocaleProvider {
4646
putLocale(locales, keys, "fr", "FR"); // French
4747
putLocale(locales, keys, "hi", "IN"); // Hindi
4848
putLocale(locales, keys, "in", "ID"); // Indonesian
49-
putLocale(locales, keys, "pt", "PT"); // Portuguese
49+
putLocale(locales, keys, "pt", "BR"); // Portuguese, Brazilian
5050
putLocale(locales, keys, "ro", "RO"); // Romanian
5151
putLocale(locales, keys, "ru", "RU"); // Russian
5252
putLocale(locales, keys, "tr", "TR"); // Turkish
@@ -57,7 +57,7 @@ public class LocaleProvider {
5757
}
5858

5959
@Nullable
60-
public static Locale getLocale(String key) {
60+
public static Locale getLocale(@Nullable String key) {
6161
if (key == null || StringsKt.isBlank(key)) {
6262
return null;
6363
}

0 commit comments

Comments
 (0)