How do I localize a string with formatting placeholders?

NSLocalizedString won’t alter your placeholders, so stringWithFormat can use them as normal. In your example, using numbered placeholders is probably a good idea –

    [NSString stringWithFormat:@"You can afford %1$i at %2$@%3$li.",
                              [kCash integerValue]/self.price, kYen,  self.price]

More info here:
Is there a way to specify argument position/index in NSString stringWithFormat?

Leave a Comment