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
Priority:  5 - Normal Item Group:  None
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open

Discussion

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

 

Attached Files

This item currently has no attached files.

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

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)
  •  

    Votes

    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.

     

    History

    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.16-8b18.
    Corresponding source code