6

I've coded a gettext wrapper that makes the whole process of l10n a little bit simpler but somehow I can't get PoEdit to correctly identify and parse plural version calls to the function. This is what I originally had:

_e(array('%d house', '%d houses'), 5);

But that doesn't work at all, PoEdit picks nothing at all. I also tried:

_e('%d house', '%d houses', 5);

This time PoEdit catches the %d house but not the plural form of %d houses, however if I try exactly the same but with a ngettext() call it works perfectly, both the singular and plural forms are identified:

ngettext('%d house', '%d house', 5);

I've correctly (?) added the _e keyword to the project settings, but it doesn't pick up plural variations. I've also noticed that PoEdit only has _, gettext and gettext_noop as the default keyworks to pick up, there is no reference whatsoever to the ngettext, dngettext or dcngettext functions but it can still correctly pick up the ngettext calls... This makes me wonder if PoEdit has hardcoded the ngettext keyword - that would be really sad.

Anyway, is there any way to make PoEdit (or any other similar app), correctly parse custom functions?

Alix Axel
  • 151,645
  • 95
  • 393
  • 500
  • Do you have at least Poedit 1.3.0? – Alex Jasmin Aug 03 '10 at 02:36
  • @Alexandre: Poedit 1.4.6 (Windows). – Alix Axel Aug 03 '10 at 02:38
  • I found this link (http://www.devcomments.com/Zend_Translate-plural-forms-and-poedit-at188420.htm) it seems that it isn't possible. Are there any alternatives? – Alix Axel Aug 03 '10 at 02:39
  • 1
    According to the [xgettext documentation](http://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/xgettext-Invocation.html), you have to add the `_e` keyword to the project (which will take the first argument only) or `_e:1,2` which will take the first and second argument and interpret them as plural forms. – caw Jul 27 '14 at 19:53

3 Answers3

10

I've found the solution, the keyword has to be defined with the following expression:

_e:1,2

Source: http://osdir.com/ml/editors.poedit.user/2008-05/msg00012.html

Alix Axel
  • 151,645
  • 95
  • 393
  • 500
3

Actually you need to do both things above.

  • Define the keyword like '_e:1,2' AND
  • Add the plural form nplurals=2; plural=n != 1;

to the catalogue settings

Deckard
  • 31
  • 1
  • 1
    Plural forms vary from language to language, and still isn't related to the problem. – Alix Axel Jun 21 '11 at 05:23
  • ngettext only supports two plural forms anyway, so what's your point? – Deckard Aug 17 '11 at 16:54
  • 1
    Actually, no. See the first (and only) example on http://php.net/manual/en/function.ngettext.php: "1 okno", "2 okna" and "5 oken". – Alix Axel Aug 17 '11 at 17:38
  • 1
    "Anyway, is there any way to make PoEdit (or any other similar app), correctly parse custom functions?" PoEdit works fine for me with a custom plural function. I defined the keywords as Deckard mentioned (or as defined in section 5.1.6 of this page http://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/xgettext-Invocation.html). – Lane Dec 28 '11 at 18:27
0

Here is another solution, it is very easy to setup. Just follow the steps below:

Menu: Catalog -> Settings will open the Settings dialog. On the Project Info tab you will find "Plural Forms" at the bottom. Just copy & paste the following line in this field:

nplurals=2; plural=n != 1;

That will fix the problem perfectly. I didn't even had to rescan the sources; the correct lines automatically appeared in the PoEditer.

Vold
  • 25
  • 1