mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-21 16:02:04 +02:00
Restore locale when returning to system default language
This commit is contained in:
@@ -32,14 +32,24 @@ public class BaseAppCompatActivity extends AppCompatActivity {
|
|||||||
public static final String PREFERENCE_APP_THEME = "app_theme";
|
public static final String PREFERENCE_APP_THEME = "app_theme";
|
||||||
public static final String PREFERENCE_LANGUAGE = "language";
|
public static final String PREFERENCE_LANGUAGE = "language";
|
||||||
|
|
||||||
|
private static Locale systemDefaultLocale = null;
|
||||||
|
|
||||||
public static Context createBaseContext(Context context) {
|
public static Context createBaseContext(Context context) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
String language = prefs.getString(PREFERENCE_LANGUAGE, "");
|
String language = prefs.getString(PREFERENCE_LANGUAGE, "");
|
||||||
if (language.isEmpty() || language.equals("default")) {
|
if (language.isEmpty() || language.equals("default")) {
|
||||||
|
if (systemDefaultLocale != null) {
|
||||||
|
Locale.setDefault(systemDefaultLocale);
|
||||||
|
systemDefaultLocale = null;
|
||||||
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (systemDefaultLocale == null) {
|
||||||
|
systemDefaultLocale = Locale.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
Locale locale;
|
Locale locale;
|
||||||
String[] localeParts = TextUtils.split(language, "-");
|
String[] localeParts = TextUtils.split(language, "-");
|
||||||
if (localeParts.length == 2) {
|
if (localeParts.length == 2) {
|
||||||
|
Reference in New Issue
Block a user