简体   繁体   中英

make multi language android application

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):

在此输入图像描述

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM