Yisus
Yisus

Reputation: 161

I want to Localize an AttributedString from my Storyboard but XCode only localizes plain text strings. Is it possible?

I've created a new project to test my real scenario, the thing is simple. I have a UILabel on my Storyboard selected as Attributed and changed some attributes like font and foreground color in order to simulate my real case. Then, added a new UILabel but this time selected as a plain text. From there, I've selected the option to localize the Storyboard in English and Spanish but the resulting String files just contain the text of UILabel plain type, leaving out the Attributed ones.

enter image description here

If I change my attributed string to plain string XCode generates both labels in the Localizable file.

I've tried to generate a new storyboard from start, using the most recent version of XCode but stills not working.

Is there something that i’m missing?

Upvotes: 0

Views: 352

Answers (1)

matt
matt

Reputation: 535027

No, you're not missing anything. It's all pretty simple: Don't Do That. If you want to localize text to be displayed via an attributed string, you'll have to build that attributed string in code, calling NSLocalizedString (or whatever) to obtain the localized text, and get it into the interface in code as well.

(Even better, save yourself a headache and don't use storyboards. But that's for another day.)

Upvotes: 1

Related Questions