using nsattributedstring and nslocalizedstring

ios, nsattributedstring, nslocalizedstring

Solution

The answer is: yes.

Yes, you need to localize sections with different attributes separately.

Problem

My old code uses NSLocalizedString to display the following where outputText was an NSMutableString that contained many such lines in a single output session: ``` [outputText appendFormat: NSLocalizedString(@"\n\n%@ and %@ are identical. No comparison required.", @"\n\n%@ and %@ are identical. No comparison required."), self.ipAddress, secAddress.ipAddress]; ``` I'm trying to change the color of the various ipAddress strings, but can't find a similar method when using NSMutableAttributedString. The biggest problem I'm facing is that since this entire string will be localized, I can't reliably set the NSRange without breaking up each part of the formatted output. Do I need to dissect each part of this string, convert it to NSAttributedString and append each piece to the outputText??

Original source