You can achieve this like following:
- Break the string into template and parameter format.
- Provide individual localization.
- Form the complete string from the template and parameter.
- Find the parameter's within the complete string and apply formats using
NSAttributedString
.
So in your case, in the Localizable.string
file will look like following
"%@ network connection" = "%@ network connection";
"Pending" = "Pending";
Now form the complete string which is localized
let complete = String(format: NSLocalizedString("%@ network connection", ""), NSLocalizedString("Pending", ""))
Then find the Range
of the parameterized string within the complete string.
let range = complete.range(of: NSLocalizedString("Pending", ""))
Now apply whatever attributes you need to apply in this range by forming NSAttributedString
.