[Q] How is it possible to order the %@ parameters correctly when using both LeftToRight text and RightToLeft text in the same string?
Context: this needs to work for the title of a NSMenuItem.
In English, I have the following format string: @"%@ - %@" and I use the following code:
NSString *myString = [NSString stringWithFormat:@"%@ - %@", @"LTR Text", @"LTR Other Text"];
Which results in @"LTR Text - LTR Other Text".
In a RightToLeft language, the @"LTR Other Text" string is going to be a "RTL Other Text". And I would like the result to be:
@"RTL Other Text - LTR Text"
I tried playing with 1$ and 2$, it did not work. @"%2$@ - %1$@" results in @"LTR Text - RTL Other Text".
I tried using stringByAppendingString: or Format: to force the ordering. It does not work. The "LTR Text" string ends up in the middle of "RTL Other Text".
I tried using the ^0 or 0^ keywords apparently used by the Finder. But this is not supported by the standard Cocoa API.
This is on macOS 10.14.6 where support for RTL text is not good in Xcode v10.1 text editors when it comes to text selection, copy-paste, and typing.