Closed n1mda closed 9 years ago
You, probably, missed -[updateAutolocalizationArguments:] call. Your code should look like this:
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSString *build = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
[myLabel.autolocalizationKey updateAutolocalizationArguments:@[version, build]];
myLabel.autolocalizationKey = @"settings.table.version";
This does not work either, it never uses the arguments. Setting autolocalizationKey
calls
[self setupAutolocalizationWithKey:autolocalizationKey keyPath:@"text"];
Which in turn calls
[self setupAutolocalizationWithKey:key keyPath:keyPath arguments:nil];
That overwrites the arguments to nil..
Sorry, you right. I typically use autolocalizationKey only in Interface Builder. Code should look like this (just different order):
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSString *build = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
myLabel.autolocalizationKey = @"settings.table.version";
[myLabel.autolocalizationKey updateAutolocalizationArguments:@[version, build]];
or
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSString *build = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
[myLabel setupAutolocalizationWithKey:@"settings.table.version" keyPath:@"text" arguments:@[version, build]];
I have a key like
"settings.table.version" = "Version %1$@ (Build %2$@)";
That I set like this:
It displays fine but when I run
dp_set_current_language(@"de");
it updates the language of the Label but does not set the arguments. Like so:Version %1$@ (Build %2$@)