【发布时间】:2016-05-03 00:08:02
【问题描述】:
所以,我正在将我的应用翻译成另一种语言。我有一些插入变量的文本,例如:
label.text = String(format: NSLocalizedString("Your name is %d", comment: "label that show user's name"), name)
现在,我转到 Localizable.strings 文件并翻译它(我不会真正翻译它):
"Your name is %d" = "Your name is %d"
但是在我的 ViewController 中,变量 %d 不是以字母形式显示,而是以随机数字形式显示,例如 782393 等。为什么会发生这种情况?一件奇怪的事情是,在一篇文章中我做了“同样的事情”:
anotherLabel.text = String(format: NSLocalizedString("Your name is %d and you have %d assignments", comment: "label that show user's name"), name, someArray.count)
翻译时:
"Your name is %d$1 and you have %d$2 assignments" = "Your name is %d$1 and you have %d$2 assignments"
奇怪的是第二个%d显示正常,数组中的对象数
这是怎么回事?
谢谢!
【问题讨论】:
标签: swift localization translation localizable.strings