bugGNU gettext - Bugs: bug #56456, xgettext doesn't separate...

 
 

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

bug #56456: xgettext doesn't separate msgid_plural and msgid when extracting

Submitter:  Michal Čihař <nijel>
Submitted:  Fri 07 Jun 2019 10:06:47 AM UTC
 
Category:  Plural forms Severity:  3 - Normal
Item Group:  None Status:  Not a Bug
Privacy:  Public Assigned to:  haible
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       No canned response available

 

( Jump to the original submission )

Wed 22 Dec 2021 03:34:28 PM UTC, comment #6: 

The aforementioned fix is contained in gettext-0.21.

Bruno Haible <haible>
Project Administrator
Sun 29 Sep 2019 07:17:13 PM UTC, comment #5: 

xgettext will now emit a warning in this case.
https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=b0d8038c1fc6cd0f549136674966388d2f562c36

Thanks for bringing up the issue.

Bruno Haible <haible>
Project Administrator
Tue 11 Jun 2019 05:58:12 PM UTC, comment #4: 

Good point, but in the end it's printed in capitals, that's why I didn't notice this. Even if the my case is not optimal I sill find this behavior weird. The problem is that it's hard to notice that these translations are not possible at all until you review that everything is translated or look into the PO files if all strings are present.

Michal Čihař <nijel>
Mon 10 Jun 2019 06:57:12 PM UTC, comment #3: 

> Well this is exactly the string where I hit the problem
> ...
> the plural string is used on landing page


As far as I understand your code, you print a number, then in a new line "Language" or "Languages".

Why does the string start with an uppercase 'L'? Isn't it more natural to use a lowercase 'l' instead, because it's not at the start of a sentence? (The sentence has started with the number.)

The other occurrence (as a table column label) would use capitalized "Language".

Bruno Haible <haible>
Project Administrator
Mon 10 Jun 2019 05:55:23 PM UTC, comment #2: 

Well this is exactly the string where I hit the problem (given that it's hidden by Django templating and string extraction, it took me some time to figure out that the actual problem lies down in the gettext). The singular string is used as table column label (so only singular is perfectly okay) and the plural string is used on landing page (eg. https://hosted.weblate.org/engage/weblate/) where it has to be pluralized to look good in non English locales.

I've already workarounded that using context as you suggest (see https://github.com/WeblateOrg/weblate/commit/61554364a0bf8ecddf8ac95cbbb1b273d75842de), but I still that's a workaround and not a proper solution.

Also I think that this might have same root cause as
https://savannah.gnu.org/bugs/?35027

Michal Čihař <nijel>
Mon 10 Jun 2019 04:43:56 PM UTC, comment #1: 

I don't see it as a bug, because your example is contrived, not realistic.
When a string is used with ngettext, it's because the string is not suitable for plural; most often it is an entire sentence. The probability is very small that the entire sentence will occur as argument of _().

When it does, the workaround is simple: just change anything in the wording of this sentence.

In situations where you are not using sentences, you can alternatively use contexts for the disambiguation.

Bruno Haible <haible>
Project Administrator
Fri 07 Jun 2019 10:06:47 AM UTC, original submission:  

When there are both simple and plural string with same singular they are extracted as only plural leaving out possibility to translate the simple form as that.

Example file (in Python, but the language doesn't seem to affect this, tested with C as well):

n = 1
ngettext("Language", "Languages", n)
_("Language")

After running xgettext test.py, I'd expect to have two entries, but there is just one:

#: test.py:2 test.py:3
msgid "Language"
msgid_plural "Languages"
msgstr[0] ""
msgstr[1] ""

This might be just different incarnation of https://savannah.gnu.org/bugs/?35027

Michal Čihař <nijel>

 

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

Attach Files:
   
   
Comment:
   

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 (Posted a comment)
  • -email is unavailable- added by nijel (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.

    Only logged-in users can vote.

     

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-06-10 haible StatusNone Not a Bug
        Assigned toNone haible
        Open/ClosedOpen Closed

    Back to the top


    Powered by Savane 3.9