我讀過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似乎是多餘的。
感謝您的幫助!