Bug 461824 - yum should use ngettext
yum should use ngettext
Status: CLOSED DUPLICATE of bug 552317
Product: Fedora
Classification: Fedora
Component: yum (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Seth Vidal
Fedora Extras Quality Assurance
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-10 16:29 EDT by Miloš Komarčević
Modified: 2014-01-21 18:06 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-04-29 12:31:10 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch for ngettext use in yum (3.22 KB, patch)
2008-11-01 21:49 EDT, Miloš Komarčević
no flags Details | Diff
Patch for ngettext use in yum, ver 2 (5.03 KB, patch)
2008-11-04 18:25 EST, Miloš Komarčević
no flags Details | Diff

  None (edit)
Description Miloš Komarčević 2008-09-10 16:29:06 EDT
ngettext should be used on strings containing plurals such as "%d packages marked for Update", as not all languages follow English plural rules.

For more details, please see e.g. http://live.gnome.org/TranslationProject/DevGuidelines/Plurals
Comment 1 Tim Lauridsen 2008-11-01 06:00:58 EDT
I agree ngettext would be a good idea, but a lot of strings need to be split up in more pieces, so patches is always welcome :)
Comment 2 Miloš Komarčević 2008-11-01 21:49:00 EDT
Tim, I cannot see which strings would need to be split, can you provide an example?

I'm attaching a patch as a starting point for using ngettext with yum.

Disclaimer: never coded in Python, so don't know if this at all correct. E.g. you might want to alias t.ungettext() in yum/i18n.py and provide some sort of a dummy wrapper just like for _().
Comment 3 Miloš Komarčević 2008-11-01 21:49:42 EDT
Created attachment 322201 [details]
Patch for ngettext use in yum
Comment 4 James Antill 2008-11-02 23:42:11 EST
 Did you test that? Where is t bound? Isn't N_() the common name for ngettext in C/etc?

 Due to yum being an API as well as a command, we can't put names into the global scope.
 Also how did you find those spots to change? As it doesn't look complete to me.
 If it was just searching for %d then you need to also look for usage like in listTransaction which does:

_("""
Transaction Summary
%s
Install  %5.5s Package(s)         
Update   %5.5s Package(s)         
Remove   %5.5s Package(s)         
""")
Comment 5 Miloš Komarčević 2008-11-03 06:12:08 EST
James, as mentioned, I haven't coded in Python at all before, so this is unfortunately untested, that's why I said it's only a starting point ;)

You're right, I did search only for %d, so I now see the need to split up more complicated cases like the one above.

As far as the aliases are concerned, i think N_() is traditionally used for gettext_noop() (i.e. just returning the untranslated string, both in C and other languages [1]), but I've seen P_() for aliasing ngettext in C header files. 

t is bound in yum/i18n.py, so I presume the ngettext alias and its dummy should go in there...

I'll try to pool some translators on the list, maybe someone knows a bit more Python so we can test this first and send a more suitable patch.

[1] http://docs.python.org/library/gettext.html#deferred-translations
Comment 6 Miloš Komarčević 2008-11-04 18:23:47 EST
Here's a second go, hope it's more formal.

Still to do, hopefully by someone more knowledgeable:

- intltool love (need to pass --keyword=P_:1,2 to xgettext somehow; a brief search suggests XGETTEXT_OPTIONS in po/Makevars or XGETTEXT_KEYWORDS in po/Makefile.in.in) so we can extract these properly in the pot file

- splitting the one outstanding string mentioned above

- removing po/pygettext.py (obsolete, doesn't even support ngettext), clean up POTFILES.skip (see e.g. notices http://translate.fedoraproject.org/module/yum)
Comment 7 Miloš Komarčević 2008-11-04 18:25:24 EST
Created attachment 322500 [details]
Patch for ngettext use in yum, ver 2
Comment 8 Bug Zapper 2008-11-25 22:01:25 EST
This bug appears to have been reported against 'rawhide' during the Fedora 10 development cycle.
Changing version to '10'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 9 James Antill 2009-03-06 15:02:16 EST
Ok I added P_ as infrastructure in commit e1931cfcfe9e97062f1291e15b0c5a02752ed282.

We can add the messages when we get the Makefile stuff etc. too.
Comment 10 James Antill 2010-04-29 12:31:10 EDT
I think the code is there now, someone just has to go through and add all the P_() stuff. So closing this as a dup of the RFE for plural forms text.

*** This bug has been marked as a duplicate of bug 552317 ***

Note You need to log in before you can comment on or make changes to this bug.