调用局部用途串行时,是否可以使用其他软件包使用捆绑包
我的应用程序在主捆绑包中具有其本地化资源(*。lproj 文件)。因此,我能够按照预期使用本地化usernotificationstring
。
从那以后,我将该应用程序模块化了,现在资源已转移到新的SPM软件包中以进行共享资源。此更改之后,本地化usernotificationstring
已停止从参数中格式化字符串。
我必须替换
NSString.localizedUserNotificationString(forKey: title, arguments: args)
为
String(format: String.localizationHelper(title), arguments: titleArgs ?? [])
interizationhelper
在资源软件包中定义的位置以使用正确的捆绑包。
func localizationHelper(key: String) {
return NSLocalizedString(key, tableName: nil, bundle: .module, value: "", comment: "")
}
My app had its localization resources (*.lproj files) in the Main bundle. So I was able to use localizedUserNotificationString
as expected.
I have since modularized the app and the resources have now moved to a new SPM package for shared resources. After this change localizedUserNotificationString
has stopped formatting strings from arguments.
I had to replace
NSString.localizedUserNotificationString(forKey: title, arguments: args)
with
String(format: String.localizationHelper(title), arguments: titleArgs ?? [])
Where the localizationHelper
is defined in the resources package to use the correct bundle.
func localizationHelper(key: String) {
return NSLocalizedString(key, tableName: nil, bundle: .module, value: "", comment: "")
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论