I\'m creating a Mac app and I want to localize my Labels. I thought a .strings
file would be a better choice. But I have trouble reading .strings
file
One. You have to name your file Localizable.strings
in the
directory in the app bundle.
Two. Use the NSLocalizedString
macro:
NSString *loc = NSLocalizedString(@"LABEL_001", nil);
Three. If nothing works, you can initialize an NSDictionary using a strings file, as a strings file is a special type of plist:
NSString *fname = [[NSBundle mainBundle] pathForResource:@"whatever" ofType:@"strings"];
NSDictionary *d = [NSDictionary dictionaryWithContentsOfFile:fname];
NSString *loc = [d objectForKey:@"LABEL_001"];