I have to localize detail-text-label using stringWithFormat with an integer value as shown below.

cell.detailTextLabel.text = 
    [NSString stringWithFormat:@"Remaining: %d", count];
有帮助吗?

解决方案

For example, assuming that "Remaining: %d" = "Remaining: %d is in your English Localizable.strings file and "Remaining: %d" = "Restante: %d is in your Spanish one, the following code will solve your particular problem:

cell.detailTextLabel.text = 
    [NSString stringWithFormat:NSLocalizedString(@"Remaining: %d", @"description for translators"), count];

If you ever need to localize a string with more than one argument, then the above solution is not flexible enough (in some languages you may need to change the order of the placeholders). You can use positional specifiers to add this kind of flexibility to your solution.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top