I was also looking for a solution, not necessarily for the iPhone, but Xcode / IB in general. All the links did not relate to the fact that you may need a internal key to indicate the status and want to display the string localized to the user in the label or text box corresponding to this key. At the first stage, I did not find a standard approach on how to store, for example, the key value for the key by default for general users and displays a localized string for this key value in the label.
I found a solution that does not need a lot of encodings and matches the bindings in ib.
First you provide a Localizable.strings file, for example. with line containing
"MyKeyValue" = "Localized display label";
Now you can localize the key value with: NSLocalizedString (aKeyValue, nil).
In the label, you did not find any value transformer associated with the NSLocalized String. Therefore, I created the KeyToLocalizedStringTransformer class to convert the key value to a localized string:
@interface KeyToLocalizedStringTransformer : NSValueTransformer {} @implementation KeyToLocalizedStringTransformer + (Class)transformedValueClass { return [NSString class]; } + (BOOL)allowsReverseTransformation { return NO; } - (id)transformedValue:(id)aValue { NSString *NLString = [NSString stringWithString:NSLocalizedString(aValue,nil)]; return NLString; }
The final step for preparation is to register a transformer, for example. in + initialize:
NSValueTransformer *transformer = [[KeyToLocalizedStringTransformer alloc] init]; [NSValueTransformer setValueTransformer:transformer forName:@"KeyToLocalizedStringTransformer"];
Now you can use the value transformer in bindings for a text field or cell (just enter a name if you only see NSUnArchiveFromData, etc.)
Sorry, there is no image here from IB, because I am new here and have no reputation: you should imagine binding to the default user controller, Kontroller key: values, model key path: MyStateKey and value converter as described.
As a result, you don’t have to do anything in a duplicated nib nib with a label, just translate the string into Localizable.strings.