0

I'm puzzled why UILabels using attributed strings are not translated when using the Storyboard/Xib - strings localization approach. I know I can use code to set it at runtime but I would like to use the default mechanism like for all other controls which don't use attributed strings.

I found questions to my exact same problem like those: 1, 2, 3, 4

But in non of those questions and answer I see no official Apple statement/documentation link why this shouldn't work (Why shouldn't it?).

So, I'm asking why is UILabel with attributed string from a Storyboard localization not supported?

And if there is no hint I would still like to know:

How to localize an UILabel with attributed string from a Storyboard?

Update

I also created a question in the apple developer forum in the hope to get an official answer.

Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92

1 Answers1

0

Apple responded on the developer forum with

This is not currently supported in Storyboard/XIB. I would encourage you to make a request on Feedback Assistant.

and ended up using this approach, see below. I still hope Apple adds the reason behind this.

- (void)localizeAttributedLabel:(UILabel*)label withText:(NSString*)text
{
  NSMutableAttributedString* attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:label.attributedText];
  [attributedString.mutableString setString:text];
  label.attributedText = attributedString;
}

[self localizeAttributedLabel:myLabel withText:NSLocalizedString(@"MyLabelTextKey", nil)];
Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92