I am trying to create a String extension to do something like that
\"My name is %@. I am %d years old\".localizeWithFormat(\"John\", 30)
w
This allows localized string with variadic arguments:
extension String {
func localizedStringWithVariables(vars: CVarArgType...) -> String {
return String(format: NSLocalizedString(self, tableName: nil, bundle: NSBundle.mainBundle(), value: "", comment: ""), arguments: vars)
}
}
Call using:
"Hello, %@. Your surname is: %@.".localizedStringWithVariables("Neil", "Peart")