Reputation: 35141
e.g.
In English:
He used <Str_1> to <Str_2>
and in Chinese:
他对 <Str_2> 使用了 <Str_1>
How can I order this two String
s (which are generated in code) differently for the code below?
[NSString stringWithFormat:@"%@ %@ %@ %@",
NSLocalizedString(@"Part1", nil), // "He used" -> "他对"
NSLocalizedString(str_1, nil),
NSLocalizedString(@"Part3", nil), // "to" -> "使用了"
NSLocalizedString(str_2", nil), nil];
I happened saw a related question before, but unluckily, I can't find it now!
The workaround is something like %2@
& %1@
to do reorder, I'm not sure.
Thanks in advance!
Upvotes: 1
Views: 167
Reputation: 23722
In your localizable.strings
file:
"He used %@ to %@" = "他对 %2$@ 使用了 %1$@";
In code:
[NSString stringWithFormat: NSLocalizedString(@"He used %@ to %@", nil),
str1, str2];
This should re-order the string parameters.
Upvotes: 6