I am trying to display a localized string that contains an argument. Instead of displaying the string in one line with the argument embedded, the result is a broken 3-line string:
Expected result:
The price is $9.99/year.
Result:
The price is (
"$9.99"
)/year.
Localizable.strings:
"price_string" = "The price is %@/year.";
Call:
"price_string".localized(priceString)
where priceString
is a String variable.
And .localized()
is defined as such:
extension String {
var localized: String {
return NSLocalizedString(self, comment: "\(self)_comment")
}
func localized(_ args: CVarArg...) -> String {
return String(format: localized, args)
}
}