我正在尝试本地化许可消息,例如允许应用程序访问相机拍摄照片或视频等
应用程序的其余部分已本地化。
这是我到目前为止所尝试的:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(App.localeManager.setLocale(base));
Log.d(TAG, "attachBaseContext");
}
public Context setLocale(Context c) {
return updateResources(c, getLanguage());
}
private Context updateResources(Context context, String language) {
Locale locale = new Locale(language);
Locale.setDefault(locale);
Resources res = context.getResources();
Configuration config = new Configuration(res.getConfiguration());
if (Utility.isAtLeastVersion(JELLY_BEAN_MR1)) {
config.setLocale(locale);
context = context.createConfigurationContext(config);
} else {
config.locale = locale;
res.updateConfiguration(config, res.getDisplayMetrics());
}
return context;
}
如果在设置中更改语言,则权限消息将被本地化。
任何帮助将不胜感激,谢谢。