调用局部用途串行时,是否可以使用其他软件包使用捆绑包

发布于 2025-01-24 11:43:08 字数 653 浏览 4 评论 0原文

我的应用程序在主捆绑包中具有其本地化资源(*。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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文