我在一个常量类中有这个静态let:
List<long[]>
我开始本地化该应用程序。 我如何本地化这种字符串?
在我的localize.string文件中使用以下代码:
struct Constants {
struct AlertsIdentifiers {
static let SERVER_RESTART_MESSAGE = """
The camera will restart now.
Please reconnect after two minutes.
"""
}
}
答案 0 :(得分:1)
您可以尝试
static let SERVER_RESTART_MESSAGE = NSLocalizedString("camReConnect", comment: "")
"camReConnect" = "The camera will restart now. \n Please reconnect after two minutes.";
最好在缩短密钥长度的同时使其可读性
答案 1 :(得分:0)
您可以在可本地化的文件中定义字符串,并在整个项目中使用它,
在Localizable.strings
文件中,
"SERVER_RESTART_MESSAGE" = "The camera will restart now.Please reconnect after two minutes.";
然后在Constants
中使用类似这样的字符串
struct Constants {
struct AlertsIdentifiers {
static let SERVER_RESTART_MESSAGE = NSLocalizedString("SERVER_RESTART_MESSAGE", comment: "")
}
}