2

有没有更好的方法来获得本地化格式并用 Xcode 8 Swift 3 替换字符串?我是否需要使用 NSString,并在 NSString 和 String 之间来回转换?

let localizedDue = NSString.localizedStringWithFormat(NSLocalizedString("Due: %@", comment: "due date label with date") as NSString, formattedDate) as String
4

1 回答 1

8

我可能遗漏了一些东西,但在 Swift 3 中,String有一个类型方法localizedStringWithFormat,您可以编写如下内容:

let localizedDue = String.localizedStringWithFormat(NSLocalizedString("Due: %@", comment: "due date label with date"), formattedDate)

如果这不是您想要的,请更新您的帖子。

于 2016-08-22T14:14:31.573 回答