Can i link a uilabel to a localizable string in Interface Builder?

Mathias picture Mathias · Sep 14, 2011 · Viewed 16.2k times · Source

have googled around but found no solution:

Basically, i have a Localizable.strings set up, which i'm using in my code. However, it would be really sweet if i somehow could just refer those values in my XIB's too, so that i can avoid having to create one annoying XIB per language...

Is this possible?

Answer

Claus Broch picture Claus Broch · Sep 14, 2011

You could implement a subclass of UILabel and have it automatically pull the localized value when it's initialized from the nib. In the XIB you would then just set the token (or english text if you prefer) and have UILabel pull the localized text from this value.