在 Swift 中使用 NSLocalizedString 继续获取 null
Keep getting null using NSLocalizedString in Swift
这是我的代码。
let arrowUp = "\u{2191}"
let percentageDif = (pctDiff(x1: yesterdayValue, x2: todaysValue)) // Exp. -27.79
let showDiffrence = String.localizedStringWithFormat(NSLocalizedString("%@ Day %@", comment: "Show Diffrence"), arrowUp, percentageDif)
虽然我不断显示“arrowUp”,但我很想为第二个获取 (null)。我尝试使用“%d”,但结果为零。从我的 Localizable.strings.
中正确翻译了“日”一词
将您的声明修改为:
let showDiffrence = "\(arrowUp) \(NSLocalizedString("Day", comment: "Show Diffrence")) \(percentageDif)"
这是我的代码。
let arrowUp = "\u{2191}"
let percentageDif = (pctDiff(x1: yesterdayValue, x2: todaysValue)) // Exp. -27.79
let showDiffrence = String.localizedStringWithFormat(NSLocalizedString("%@ Day %@", comment: "Show Diffrence"), arrowUp, percentageDif)
虽然我不断显示“arrowUp”,但我很想为第二个获取 (null)。我尝试使用“%d”,但结果为零。从我的 Localizable.strings.
中正确翻译了“日”一词将您的声明修改为:
let showDiffrence = "\(arrowUp) \(NSLocalizedString("Day", comment: "Show Diffrence")) \(percentageDif)"