我已经开始翻译我的应用程序,这是我第一次这样做,但是直到现在,每个用户界面都可以通过添加新语言来轻松翻译,并翻译很容易翻译新的Main.strings (Italian)
中的值是我现在正在使用的值。我的问题始于我在远程通知中使用的NSLocalizedString
。我不会从Xcode中获得任何错误,但是一旦我将这些翻译添加到Main.strings (Italian)
文件中,就比设备上的接口返回到英语,如果我评论了翻译,则使用设置语言。我必须在其他地方放置NSLocalizedString
的翻译,还是在这里做错了什么?我看了其他帖子,解决方案几乎就像我在这里做事一样。一如既往的感谢。这就是我这样做的方式:
远程通知:
PushNotifications.sendPushNotification(to: customerFcmToken, title: String(format: NSLocalizedString("Order number: %1@", comment: ""), orderId), subtitle: String(format: NSLocalizedString("Shop: %1@", comment: ""), UserDetails.fullName!),body: String(format: NSLocalizedString("Thank you %1@! We received your order and we'll let you know when we start preparing it and when it's ready. Bye", comment: ""), customerName))
main.strings(意大利语(中的翻译
"Order number: %1@" = "Ordine numero: %1@"
"Shop: %1@" = "Negozio: %1@"
"Thank you %1@! We received your order and we'll let you know when we start preparing it and when it's ready. Bye" = "Grazie %1@! Abbiamo ricevuto il tuo ordine e ti faremo sapere quando cominceremo la sua preparazione e quando sarà pronto per essere ritirato. Ciao."
找到了问题。它实际上与整个本地化有关,所以我将为其他苦苦挣扎的其他人留下正确的步骤。
添加新语言之前:
-
从
addFile
命令创建一个新的字符串文件。将其命名为本地化。 -
在属性Inspector中,从下拉菜单中选择了
English
。它不会显示(Base)
。 -
现在添加一种新语言。现在,它将为
Localizable.string
文件创建本地化文件。 -
添加您将在代码中使用的所有
NSLocalizableString
的键/值对。如果缺少该文件是可读的,请不要错过;
。
所以现在代码为:
英语:
// Order Revceived
"orderReceivedTitle" = "Order number: %1@";
"orderReceivedSubtitle" = "Shop: %1@";
"orderReceivedBody" = "Thank you %1@! We received your order and we'll let you know when we start preparing it and when it's ready. Bye";
意大利语:
// Order Revceived
"orderReceivedTitle" = "Ordine numero: %1@";
"orderReceivedSubtitle" = "Negozio: %1@";
"orderReceivedBody" = "Grazie %1@! Abbiamo ricevuto il tuo ordine e ti faremo sapere quando cominceremo la sua preparazione e quando sarà pronto per essere ritirato. Ciao.";
推送通知:
PushNotifications.sendPushNotification(to: customerFcmToken, title: String(format: NSLocalizedString("orderReceivedTitle", comment: ""), orderId), subtitle: String(format: NSLocalizedString("orderdReceivedSubtitle", comment: ""), UserDetails.fullName!),body: String(format: NSLocalizedString("orderReceivedBody", comment: ""), customerName))
这将以发送设备设置为语言发送远程通知,并且接收设备将以该语言获取。
下一步是在兔子中显示远程通知,即接收设备设置为。
为此,已发送有效负载必须使用"loc-key"
和"loc-args"
,并且在接收设备上的Localizable.string
文件中也将这些负载在两个相关应用程序上使用远程通知:SHOP(SENDing(和客户(接收(。我将在完成后立即更新答案。