有什么方法可以在Android中本地化棉花糖权限字符串吗?

时间:2019-03-28 06:22:29

标签: android localization android-permissions

我正在尝试本地化权限消息,例如允许应用访问相机以拍摄照片或视频

其余应用已本地化。

这是我到目前为止尝试过的:

@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;
}

还有一件事,如果更改设置中的语言,权限消息将被本地化。

我们将不胜感激,谢谢。

1 个答案:

答案 0 :(得分:0)

不。权限请求对话框显示在设备的区域设置中。