问题描述
我创建了多语言(英语,俄语,乌兹别克斯坦)应用程序.我在文档.当我更改应用程序语言更新时,将在App Controller中进行资源配置,如下所示:
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());
此后,通过调用如下所示的App控制器的方法重新启动App:
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);
}
在他们之后,几乎所有设计都运作良好.但是在三星银河S6(SM-G920F)上,它的工作就像疯了一样.有些单词是英语,有些则是乌兹别克语和ets.那么,如何解决此错误?不是所有设备都支持支持不同语言"的概念吗?顺便说一句,我检查了所有资源是否都以相应的语言提供(如附图所示):
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):
推荐答案
根据我的观察,怪异的行为仅影响活动标题,并且我发现我在清单文件中设置了活动标题的翻译.仅这些翻译有不当行为.所有其他动态设置的翻译都可以正常工作.因此,为解决此问题,我从清单文件中删除了所有活动标签,然后在onCreate方法中设置活动标题,如下所示:
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);
问题解决了.
这篇关于制作多国语言的android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!