我读过GNU Gettext manual about Translating plural forms,看看它的例子:为什么在gettext转换文件中必须使用msgid_plural?
#, c-format
msgid "One file removed"
msgid_plural "%d files removed"
msgstr[0] "%d slika je uklonjena"
msgstr[1] "%d datoteke uklonjenih"
msgstr[2] "%d slika uklonjenih"
为什么从MSGID msgid_plural不同,不在于打败有翻译了解复数形式的目的是什么?
我认为我可以做这样的事情(英文):
#, c-format
msgid "X geese"
msgstr[0] "%d goose"
msgstr[1] "%d geese"
#, c-format
msgid "sentence_about_geese_at_the_lake"
msgstr[0] "There is one goose at the lake."
msgstr[1] "There are %d geese at the lake."
(只使用一个MSGID)。在我的代码
然后,我会碰到这样的:
<?php echo $this->translate('X geese', $numberA); ?>
<?php echo $this->translate('sentence_about_geese_at_the_lake', $numberB); ?>
如果$ numberA是3,它会说: “3个鹅。”
如果$ numberB为0,则下一行将会显示“湖中有0只鹅”。
(因为对于英语,规则是(N!= 1),所以复数用于任何数量的比等于1 0或更大)。
对于我来说,为同一个短语集合指定2个msgids似乎是多余的。
感谢您的帮助!