I would like to know if, without changing the Locale
of the app, there is some possibility to choose which file of strings.xml
to use in the app.
For example, if I have a file of strings.xml
and when translating this I have created a new strings.xml(en)
, do that, if I want it, when the Locale is es_ES use the second file, that is, the string.xml (en).
Is it possible to do this? If it is not, would it be worth changing the Locale to use one resource or another?
From what I've read, it's supposed to be. However, I have done it and it does not work.
Code:
Locale aLocale = new Locale.Builder().setLanguage("en").setRegion("US").build();
Locale.setDefault(aLocale);
getResources().getConfiguration().setLocale(aLocale);
Locale current = getResources().getConfiguration().locale;
Toast.makeText(getApplicationContext(), Locale.getDefault().getCountry()+Locale.getDefault().getLanguage(), Toast.LENGTH_LONG).show(); //muestra USen
Toast.makeText(getApplicationContext(), Locale.getDefault().getDisplayLanguage(), Toast.LENGTH_LONG).show();//muestra English
Toast.makeText(getApplicationContext(),current.toString(), Toast.LENGTH_LONG).show();//muestra en_US
Despite these results, the text does not change.