1

Here is my case: I use gettext via Poedit to translate a PHP application. And I have a custom function for plurals:

function ListOutput($result,$column_names,$singular='.',$plural='.',$link=false,$group=array(),$options=array())

Which is referenced in Poedit with this keyword: ListOutput:3,4.

Now, my problem is that when I have a string to translate, I use _('example_string'), but then if I translate it later via ListOutput($result,$column_names,'example_string', 'example_string_plural') , only example_string will appear in Poedit.

And furthermore, I should say that this problem appears at time, other times, I will have the plural form AND the singular form (so, the singular string 2 times...).

Note 1: that if the strings are only referenced in ListOutput(), the plural form will correctly appear in Poedit.

Note2: ListOutput() function calls ngettext() with the number of elements of the list as the 3rd argument.

Francois J
  • 31
  • 4
  • No one can not think what is happening in your own function ListOutput(). Please make the minimum code which reproduces your problem, that would be probably calling ngettext() with your parameters. – akky Mar 08 '13 at 03:23

1 Answers1

0

I'm not surprised by this xgettext behavior. In Gettext, the (untranslated) string is the ID -- you can't have two different entries with the same ID in a catalog. It wouldn't make any sense, would it?

You're asking xgettext to write msgid "example_string" into the ePO catalog with two conflicting definitions: either as single-form entry (from the _() occurrence) or as an entry with plural forms (from ListOutput() call). It would be better if it reported an error, but it's not entirely surprising that it just picks the first definition either.

It seems fishy anyway -- how could the same string be correctly used in both ways? More likely than not, one of the two uses is incorrect. If it really is legitimate, you can use msgctxt to disambiguate the two strings.

Václav Slavík
  • 6,445
  • 2
  • 28
  • 25
  • 1
    Haha, stumbled uppon this behaviour right today. This is a flaw IMHO for PO format / xgettext to consider that msgid could conflict with a plural form. msgid for plural form should be concatenation of singular and plural, this should be possible to handle both form in a PO catalog. If not, at least throw an intelligible error saying there is a conflict, not just erasing one by the other :( – guillaumepotier Sep 30 '15 at 16:51