开发者

generating Localizable.strings creates strange output

When I use genstrings -o en.lproj *.m it generates the Localizable.strings file with entries in this structure:

/* this is the text: %@  ID: %02X */

"this is the text: %@  ID: %02X" = "this is the text: %1$@  ID: %2$X";

Please notice that it开发者_如何学编程 makes from %@ -> %1$@

Why is this? I always have to change it back to %@ manually.

Thanks


Did you use the "-j" option? It produces java localized string (which have the format like %1$@).

[EDIT]

Sorry, looked at the wrong manual page. Please use the option -noPositionalParameters to turn off generation of positional parameters. -> Info's here


You don't need to change it back, since %1$@ refers to the first argument given to your format string.

Actually, in a case different from yours, it might happen that the order of the arguments changes from a translation to another. For example, if your code uses a format to display some player property value like:

let fmt = NSLocalizedString("Player property value", comment: "The player property value")
String(format:fmt, playerName, playerProperty, value)

You might have in the "en.lproj/Localizable.strings":

/* The player property value */
"Player property value" = "Player %1$@'s %2$@ is %3$d"

and in the "fr.lproj/Localizable.strings":

/* The player property value */
"Player property value" = "Le %2$@ du joueur %1$@ is %3$d"

or:

/* The player property value */
"Player property value" = "Le joueur %1$@ a %3$d points de %2$@"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜