我正在try 使用NSLocalizedString本地化我的应用程序.当我导入XLIFF文件时,大多数工作都很出色,但有些不是,有些字符串没有本地化.我注意到问题出在NSLocalizedString内部包含一些变量,例如:

NSLocalizedString(" - \(count) Notifica", comment: "sottotitolo prescrizione per le notifiche al singolare")

NSLocalizedString("Notifica per \(medicina!) della prescrizione \(prescription!)\nMemo: \(memoTextView.text)", comment: "Messaggio della Local Notification")

Maybe this is not the c或rect syntax f或 this kind of stuff. Someone can explain me how to do that in Swift?

推荐答案

您可以使用NSLocalizedString内的sprintf个格式参数,因此您的示例如下所示:

let myString = String(format: NSLocalizedString(" - %d Notifica", comment: "sottotitolo prescrizione per le notifiche al singolare"), count)

Ios相关问答推荐

使用CGAffineTransform旋转视图只起作用一次吗?

如何在Android或iPhone上的原生react 中处理其他应用程序通知?

IOS-获取本地化系统映像

无法关闭包含字体 Select 器的工作表

为什么IOS多行文本输入在React原生纸张对话框中无法正常工作?

如何在 Flutter 应用程序中测试来自 App/Play Store 的移动深层链接?

使用 Xamarin 将 dext Bundle 到 iOS .ipa 中

@MainActor 类的扩展是主要演员吗?

Swift Combine 防止初始值触发接收器并同时防止重复?

NSOperation 有延迟 - 它是异步的还是同步的?

如何让替换视图淡入旧视图而不是交叉淡入淡出?

SwiftUI:如何为 ScrollView 制作可拉伸(灵活)的粘性标题?

SwiftUI 我自己的渲染函数的返回类型是什么?

UIButton在iOS7中没有显示突出显示

滑动列表项以获取更多选项(Flutter)

Xcode 4 + iOS 4.3:存档类型不存在打包程序

如何关闭 iOS 键盘?

如何防止 iOS 设备上的显示屏变暗和关闭?

如何删除UITableView中最后一个单元格的最后一个边框?

如何找到 UILabel 的实际行数?