Reputation: 2209
I have this static let in a constants class:
struct Constants {
struct AlertsIdentifiers {
static let SERVER_RESTART_MESSAGE = """
The camera will restart now.
Please reconnect after two minutes.
"""
}
}
I am starting to localize the app. How can i localize that kind of string?
In my localize.string file is use this code:
"The camera will restart now.Please reconnect after two minutes." = "The camera will restart now.Please reconnect after two minutes.";
Upvotes: 1
Views: 1093
Reputation: 9642
You can define your strings in localizable file and use it across the project,
In Localizable.strings
file,
"SERVER_RESTART_MESSAGE" = "The camera will restart now.Please reconnect after two minutes.";
Then in Constants
use the string like,
struct Constants {
struct AlertsIdentifiers {
static let SERVER_RESTART_MESSAGE = NSLocalizedString("SERVER_RESTART_MESSAGE", comment: "")
}
}
Upvotes: 0
Reputation: 100503
You can try
static let SERVER_RESTART_MESSAGE = NSLocalizedString("camReConnect", comment: "")
"camReConnect" = "The camera will restart now. \n Please reconnect after two minutes.";
It's a good practice to shorten the length of the key at the same time of making it readable
Upvotes: 1