Explicit Ordering of Tokens in Format Strings

As text is moved from language to language, both the words and the order of the words change. For example, the words in one language may be laid out like this: “Ted needs a scooter.” In another, the order might be “A scooter is what Ted needs.” Suppose that you try to localize the format string to be used like this:

l​e​t​ ​f​o​r​m​a​t​ ​=​ ​N​S​L​o​c​a​l​i​z​e​d​S​t​r​i​n​g​(​"​N​E​E​D​S​"​,​ ​c​o​m​m​e​n​t​:​ ​"​%​@​ ​n​e​e​d​s​ ​a​ ​%​@​"​)​
l​e​t​ ​s​t​r​i​n​g​ ​=​ ​S​t​r​i​n​g​(​f​o​r​m​a​t​:​ ​f​o​r​m​a​t​,​ ​"​I​"​,​ ​"​H​e​r​o​"​)​

The following will work fine for the first language:

"​N​E​E​D​S​"​ ​=​ ​"​%​@​ ​n​e​e​d​s​ ​a​ ​%​@​"​;​

For the second language, you would need ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.