[Solved] How to change the application language by user choice?


Although its not recommended to use separate language for your app other than the Android system’s . But you can still change it .

Below is the code :

private void setLocale (String localeCode , Bundle b ){
    Log.d(TAG+"set location function: "+localeCode);
    locale = new Locale(localeCode);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
    getApplicationContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
    UserDetail.this.getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
    onCreate(null);
}

Use this method call on some user trigger:

setLocale("en-us",savedInstanceStat); // for english
setLocale("ar",savedInstanceStat); // for arabic

To learn more about android locals:
http://www.icanlocalize.com/site/tutorials/android-application-localization-tutorial/

solved How to change the application language by user choice?