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

Submitted by:  Guido Flohr <gflohr>
Submitted on:  Tue 05 Jul 2016 02:32:44 PM UTC  
 
Category: Plural formsSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned 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>
Project 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>
Project Member

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 27 Nov 2016 12:14:37 PM UTChaibleCategoryNone=>Plural forms

    Back to the top


    Powered by Savane 3.1-cleanup1