【问题标题】:How to add variable in Localizable swift如何在Localizable swift中添加变量
【发布时间】:2020-05-01 09:04:18
【问题描述】:

我为我的问题寻找解决方案。如果我在 localizable.string 中有一个字符串,例如:

"stringExample" = "My name is ";

如何正确添加名称? 我不想做string = string + "userName"

有什么办法吗?

【问题讨论】:

标签: swift localizable.strings


【解决方案1】:

您可以使用"stringExample = "My name is %@";,并使用本地化字符串作为字符串格式:

let fmt = NSLocalizedString("stringExample", "")
let myNameIs = String(format: fmt, "Max")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-20
    • 1970-01-01
    • 2020-03-16
    • 2020-12-03
    • 2020-02-05
    • 2017-09-11
    相关资源
    最近更新 更多