April 2015
Intermediate to advanced
556 pages
17h 47m
English
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:
let format = NSLocalizedString("NEEDS", comment: "%@ needs a %@")
let string = String(format: format, "I", "Hero")
The following will work fine for the first language:
"NEEDS" = "%@ needs a %@";
For the second language, you would need to explicitly indicate the index of the token you want to insert. This is done with a number and the dollar sign:
"NEEDS" = "A %2$@ is ...
Read now
Unlock full access