当我使用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$@生成的
为什么会这样呢?我总是需要手动将它改回%@。
谢谢
发布于 2011-09-29 17:16:30
您是否使用了"-j“选项?它会生成java本地化字符串(其格式类似%1$@)。
编辑
对不起,看错手册页了。请使用选项-noPositionalParameters关闭位置参数的生成。-> Info's here
发布于 2016-05-31 17:08:04
您不需要将其改回原处,因为%1$@引用了格式字符串的第一个参数。
实际上,在与您的情况不同的情况下,参数的顺序可能会从一个翻译更改为另一个翻译。例如,如果您的代码使用一种格式来显示某些播放器属性值,如下所示:
let fmt = NSLocalizedString("Player property value", comment: "The player property value")
String(format:fmt, playerName, playerProperty, value)您可能在“en.lproj/Localizable.string”中有:
/* The player property value */
"Player property value" = "Player %1$@'s %2$@ is %3$d"在“fr.lproj/Localizable.string”中:
/* 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$@"https://stackoverflow.com/questions/7593982
复制相似问题