• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps App translation (android studio)

jvb2008

Lurker
Nov 22, 2016
1
0
Hello,

I am developing an android app in android studio and I want to translate the app in two languajes. I have develop the following code in order to translate all my activities. It is codify only in the login activity (the main one). With this code it not translates all the activities at once. Do I have to create code in the rest of activities too?
Thanks and regards.

public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.espanol:
Locale locale_es = new Locale("es");
Locale.setDefault(locale_es);
Configuration config_es = new Configuration();
config_es.locale = locale_es;
getBaseContext().getResources().updateConfiguration(config_es, getBaseContext().getResources().getDisplayMetrics());
recreate();
break;

case R.id.english:
Locale locale_en = new Locale("en");
Locale.setDefault(locale_en);
Configuration config_en = new Configuration();
config_en.locale = locale_en;
getBaseContext().getResources().updateConfiguration(config_en, getBaseContext().getResources().getDisplayMetrics());
recreate();
break;

}
return super.onOptionsItemSelected(item);
}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones