Created
September 6, 2019 13:55
-
-
Save foxfriends/9f7f372703b5610aece9529373e32cb1 to your computer and use it in GitHub Desktop.
Wrapper around NSLocalizableString to make it a lot easier to use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
/// Loads the localized version of the current string | |
@inline(__always) | |
func localized(comment: String = "") -> String { | |
return NSLocalizedString(self, comment: "") | |
} | |
/// Loads the localized version of the current string, interpolating the provided values into the string | |
func localized(comment: String = "", _ args: CVarArg...) -> String { | |
return withVaList(args) { | |
NSString(format: localized(comment: comment), arguments: $0) as String | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment