I use next solution:
1) create extension:
extension String {
var localized: String {
return NSLocalizedString(self, tableName: nil, bundle: Bundle.main, value: "", comment: "")
}
}
2) in Localizable.strings file:
"Hi" = "Привет";
3) example of use:
myLabel.text = "Hi".localized
enjoy! ;)
--upd:--
for case with comments you can use this solution:
1) Extension:
extension String {
func localized(withComment:String) -> String {
return NSLocalizedString(self, tableName: nil, bundle: Bundle.main, value: "", comment: withComment)
}
}
2) in .strings file:
/* with !!! */
"Hi" = "Привет!!!";
3) using:
myLabel.text = "Hi".localized(withComment: "with !!!")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…