Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
extension String {
func localized(_ args: CVarArg...) -> String {
return String(format: NSLocalizedString(self, comment: ""), arguments: args)
let format = NSLocalizedString("Hello %@", comment: "")
print(String(format: format, "World"))
print("Hello %@ %@".localized("Worlds", "Fair"))
let format2 = "Hello %@ %@"
print(format2.localized("Worlds", "Fair"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.