I have a String extension that helps me internationalise.
public extension String {
var localized: String {
return NSLocalizedString(self, tableName: nil, bundle: Bundle.main, value: "", comment: "")
}
func localized(args:CVarArg...) -> String{
return NSString.localizedStringWithFormat(self.localized as NSString, args) as String
}
}
This way I can easily use "hello_world".localized anywhere in the app and it works nicely.
Now I want to have the same functionality, but also want to be able to pass arguments. However passing the 'CVarArg...' doesn't seem to work as I'd expect it to.
"grant_gps_access".localized("MyApp")
Expected result: "Please grant MyApp GPS access"
Actual result: "Please grant (\n MyApp\n) GPS access"
What am I missing here?