mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-20 05:20:14 -07:00
37 lines
1.1 KiB
Java
37 lines
1.1 KiB
Java
package net.kdt.pojavlaunch.utils;
|
|
|
|
import android.content.*;
|
|
import android.content.res.*;
|
|
import androidx.preference.*;
|
|
import java.util.*;
|
|
import net.kdt.pojavlaunch.prefs.*;
|
|
|
|
public class LocaleUtils {
|
|
public static final Locale DEFAULT_LOCALE;
|
|
|
|
static {
|
|
DEFAULT_LOCALE = Locale.getDefault();
|
|
}
|
|
|
|
public static Context setLocale(Context context) {
|
|
if (LauncherPreferences.DEFAULT_PREF == null) {
|
|
LauncherPreferences.DEFAULT_PREF = PreferenceManager.getDefaultSharedPreferences(context);
|
|
LauncherPreferences.loadPreferences();
|
|
}
|
|
|
|
Locale locale;
|
|
if (LauncherPreferences.PREF_LANGUAGE.equals("default")) {
|
|
locale = DEFAULT_LOCALE;
|
|
} else {
|
|
locale = new Locale(LauncherPreferences.PREF_LANGUAGE);
|
|
}
|
|
|
|
Locale.setDefault(locale);
|
|
|
|
Resources res = context.getResources();
|
|
Configuration config = new Configuration(res.getConfiguration());
|
|
config.setLocale(locale);
|
|
context = context.createConfigurationContext(config);
|
|
return context;
|
|
}
|
|
}
|