5

I created multi language (English, Russian, Uzbek) app. I put 4 string resoureses in 4 folders (values, values-en, values-ru, values-uz) as docs. When I change app language updates resourses configuration in App Controller like below:

 Settings.LANGUAGE = prefs.getString(User.LANG, Settings.RUSSIAN);
 Locale locale = new Locale(Settings.LANGUAGE);
 Locale.setDefault(locale);
 Configuration configuration = new Configuration();
 configuration.locale = locale;
 getBaseContext().getResources().updateConfiguration(configuration,
     getBaseContext().getResources().getDisplayMetrics());

After that App restarts by calling App controller's method like below:

public void reStart() {
    Intent i = getBaseContext().getPackageManager()
            .getLaunchIntentForPackage(getBaseContext().getPackageName());
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(i);
}

After them It works well almost all devises. But on Samsung Galaxy S6 (SM-G920F), it works as crazy. Some words are in english and others are in Uzbek and ets. So, How to fix this error? isn't the concepts of "Supporting Different Languages" supported by (applicable to) all devices? By the way, I have checked that all resources are given in corresponding languages (as shown in attached image):

enter image description here

Hyyan Abo Fakher
  • 3,497
  • 3
  • 21
  • 35
Akbar
  • 430
  • 4
  • 18
  • Samsung likes to do there own thing.... :[ I've found that they don't always follow standards (for a few things) – Neil Locketz Sep 27 '16 at 14:38
  • Do you get the same issue when changing the device language instead of programmatically like that? – DeeV Sep 27 '16 at 14:40
  • What I have to do then? @NeilLocketz – Akbar Sep 28 '16 at 09:03
  • 1
    You don't need to change the language programmatically, the language must be the defined by the user settings. When he change the device language, your resources will change automatically – Lucas Queiroz Ribeiro Sep 28 '16 at 11:51
  • The app is being created for polyglot audience. Swithching language from inside the app is required. This feature has been explicitely requested by the client. – Akbar Sep 28 '16 at 14:55

1 Answers1

2

From my observations, weird behaviour was affecting only Activity titles, and I found that I was setting translations of activity titles in Manifest file. Only these translations were misbehaving. All other dynamically set translations were working fine. So, to fix the problem, I removed all activity labels from Manifest file, then set activity titles in onCreate method as below:

getSupportActionBar().setTitle(R.string.title_activity_followers);

Problem solved.

Akbar
  • 430
  • 4
  • 18