How to create an formatted localized string?
- by mystify
I have an 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 for the moment.
How would I provide NAMED variables in an 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?