相关疑难解决方法(0)

为什么在 gettext 翻译文件中需要 msgid_plural?

我已经阅读了关于翻译复数形式GNU Gettext 手册并查看其示例:

 #, 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"
Run Code Online (Sandbox Code Playgroud)

为什么 msgid_plural 与 msgid 不同,这不会破坏让翻译了解复数形式的目的吗?

我认为我可以做这样的事情(英语):

 #, 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."
Run Code Online (Sandbox Code Playgroud)

(仅使用一个 msgid)。

然后在我的代码中,我会有类似的东西:

<?php echo $this->translate('X geese', $numberA); ?> 
<?php echo $this->translate('sentence_about_geese_at_the_lake', $numberB); …
Run Code Online (Sandbox Code Playgroud)

translation zend-framework gettext

5
推荐指数
1
解决办法
1667
查看次数

标签 统计

gettext ×1

translation ×1

zend-framework ×1