生成Localizable.strings会产生奇怪的输出

时间:2011-09-29 07:38:01

标签: iphone localization

当我使用genstrings -o en.lproj *.m时,它会生成带有此结构条目的Localizable.strings文件:

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

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

请注意它来自%@ -> %1$@

这是为什么?我总是需要手动将其更改为%@

由于

2 个答案:

答案 0 :(得分:0)

您使用“-j”选项吗?它生成java本地化字符串(格式为%1 $ @)。

[编辑]

抱歉,查看了错误的手册页。请使用选项-noPositionalParameters关闭位置参数的生成。 - > Info's here

答案 1 :(得分:0)

您不需要更改它,因为%1$@是指给您的格式字符串的第一个参数。

实际上,在与您的情况不同的情况下,可能会发生参数的顺序从翻译变为另一种情况。例如,如果您的代码使用格式显示某些播放器属性值,例如:

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

您可能拥有" en.lproj / Localizable.strings":

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

和" fr.lproj / Localizable.strings":

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

或:

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