PoEdit keywords - plurals

孤人 提交于 2019-12-04 04:52:40

gettext only deals with one string at a time. What you may be after is ngettext. (look it up for syntax)

There, you'll put in one text for singular, another for plural, but also the number.

The smart thing about this is, that many languages have a totally different plural structure, than English. Russian, for instance, uses three different forms. One is for where the count ends in a pronounced 'one': 1, 21, 31, 41 etc. The second form is for counts, which end in a pronounced 2, 3 or 4. The third form is for the rest...

And, with ngettext, this can be done. Yeah, in poedit, one has to correctly define the target language's plural structure, but then, it just works.

http://www.gnu.org/s/hello/manual/gettext/Plural-forms.html

Like Tor-Bjorn Fjellner has answered, this actually should just work.

If you tell poedit that the language actually has plural forms (Translating Plural Forms with Poedit) and taken your keywords into account, poedit offers them for translation.

Example

Plural Forms: nplurals=2; plural=n != 1;

Keywords:

  • t:2
  • t:2,3

PHP Code:

<?php

t("cat", "strA");

t("cat", "strB1", "strB2", 2, array());

t("cat", "strC1", "strC2", 3, array());

Poedit UI:

What I didn't understand in your question was the point about the arrays and such. I could not decipher what you're intending to in the poedit/gettext domain, I think your question would benefit if you add some concrete code examples and how the outcome should be for them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!