DRY String Localization with Interface Builder
Victor Pavlychko

Was getting some warnings about deprecated string APIs on Xcode 9 with your implementation. This code fixes them (apologies for the indentation):

public func localize(_ string: String?) -> String? {

guard let term = string, term.hasPrefix(“@”) else {

return string


let key = String(term.suffix(from: term.index(after: term.startIndex)))

return term.hasPrefix(“@@”) ? key : NSLocalizedString(key, comment: “”)