bugGNU gettext - Bugs: bug #48411, xgettext does not detect...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #48411: xgettext does not detect conflicting plural forms

Submitter:  Guido Flohr <gflohr>
Submitted:  Tue 05 Jul 2016 02:32:44 PM UTC
   
 
Category:  Plural forms Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Tue 05 Jul 2016 03:10:25 PM UTC, comment #2: 

Sure, Michele.  Nonetheless xgettext must bail out in this case instead of silently recycling the plural form of another message.

Guido Flohr <gflohr>
Group Member
Tue 05 Jul 2016 03:04:40 PM UTC, comment #1: 

I don't think it's possible to have two different entries in the .po / .mo file with the same msgid.
That's because every entry is identified by msgid (or msgctx + \x04 + msgid if the context is present), the msgid_plural is not part of the key...

Michele Locati <mlocati>
Tue 05 Jul 2016 02:32:44 PM UTC, original submission:  

Run this piece of C code through xgettext:

  printf(ngettext("One network.\n", "%s networks.\n", count), "Many");
  printf(ngettext("One network.\n", "%lu networks.\n", count), count);

You will get one single po entry:

  #: network.c:1 network.c:2
  #, c-format
  msgid "One network.\n"
  msgid_plural "%s networks.\n"
  msgstr[0] ""
  msgstr[1] ""

In the example code this is likely to cause a segmentation fault.  Yes, sure, the example does not make a lot of sense but it is perfectly legal usage of ngettext and illustrates the problem.

The best solution would probably be to use the combination of the singular and plural message id as the key into the translation catalog.  But that would not be possible without changing the gmo format.

But xgettext should at least treat this situation as a fatal error condition.

In case somebody runs into this problem in a real-world application: Use npgettext() instead of ngettext() and add a message context as a workaround!

Guido Flohr <gflohr>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Updated the item)
  • -email is unavailable- added by mlocati (Posted a comment)
  • -email is unavailable- added by gflohr (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-27 haible CategoryNone Plural forms

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code