A cup of Objective c

viernes, 25 de abril de 2014

Interfaz builder localization

Localizing your app is really important.There are two main technics:1. Localizing your xib. Then you end with a lot of repeated files.2. Localizing your file in the viewDidLoad method, better but you have to define your uilabel only to localized it.Or you can take advanced of the User Defined Runtime Attributes, on the Interface Builder.First define a new category for UILabel:

#import "UILabel+Localized.h"

@implementation UILabel (Localized)

-(void) setTextLocalized:(NSString *)aText{

[selfsetText:NSLocalizedString(aText, nil)];

}

@end

Of course you need to define your localized.strings and fill all the string you want to localize.And finally in the interfaz builder: