I developed an app on spanish and later translate it to catalan. But they told me to make catalan the default language.
I have a values folder with the strings.xml (Catalan) and a values-es folder with strings.xml (Spanish). I assumed the app would load the first language but it launches in spanish.
On the preferences xml I set the default to be "ca":
<ListPreference
android:key="pref_idioma"
android:title="@string/idioma"
android:summary="@string/selecciona_idioma"
android:dialogTitle="@string/idioma"
android:defaultValue="ca"
android:entries="@array/idiomas"
android:entryValues="@array/idiomasinterno" />
I use Shared Preferences so the user can chose the language he wants and that works. If he choses Catalan, the language loads correctly.
if(preference.getKey().equals("pref_idioma")){
Locale myLocale = new Locale(newValue.toString());
Locale.setDefault(myLocale);
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = new Configuration();//res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
ClassCOM.setIdioma(getApplicationContext(), newValue.toString());
finish();
startActivity(getIntent());
}
It just bothers me that when the user installs the app, it's in spanish and I can't see why.
Thank you.