How to create a formatted localized string?
- by mystify
I have a localized string which needs to take a few variables. However, in localization it is important that the order of the variables can change from language to language.
So this is not a good idea:
NSString *text = NSLocalizedString(@"My birthday is at %@ %@ in %@", nil);
In some languages some words come before others, while in others it's reverse. I lack of an good example at the moment.
How would I provide NAMED variables in a formatted string? Is there any way to do it without some heavy self-made string replacements? Even some numbered variables like {%@1}, {%@2}, and so on would be sufficient... is there a solution?