通知的本地化不起作用 [英] Localization of notifications does not work

查看:48
本文介绍了通知的本地化不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想本地化通知,我发现有这样的属性,比如title_loc_key、body_loc_key

I want to localize notification , and i find that there is properties for that , like title_loc_key, body_loc_key

用于本地化 (I18N) 通知标题和正文的 FCM 字段不起作用.例如:

he FCM fields used for localizing (I18N) the notification title and body are not working. For example:

{
  "android" : {
    "priority" : "normal",
    "notification" : {
      "title_loc_key": "notify_title",
      "body_loc_key": "notify_body"
    }
  }
}

FCM 文档指出,这些字段用于本地化应用程序的字符串资源"中的文本,但 Flutter 没有 res/values/strings.xml 文件.我正在使用 flutter_localizations 库,并按照 Flutter 的国际化要求维护 res/values/strings_.arb 文件,但我无法告诉 firebase_messaging 使用这些资源.

The FCM documentation states that these fields are used to localize the text in the "app's string resources", but Flutter does not have a res/values/strings.xml file. I am using the flutter_localizations library, and maintain res/values/strings_.arb files as required by Flutter for internationalization, but there is no way for me to tell firebase_messaging to use these resources.

谢谢

推荐答案

FCM 不知道 Flutter.它专注于本机应用程序.所以对于 Flutter,这将是 androidios 目录中的代码.

FCM isn't aware of Flutter. It focuses on the native apps. So for Flutter, this would be the code within the android and ios directories.

如果你想使用title_loc_keybody_loc_key,你必须给android/app/src/main/res/values/strings 添加标签.xml 在 Android 上.这些与您在 Flutter 代码中使用的标签是分开的.

If you want to use title_loc_key and body_loc_key, you'll have to add labels to android/app/src/main/res/values/strings.xml on Android. Those are separate from the labels you use within your Flutter code.

这篇关于通知的本地化不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆