Red Hat Bugzilla – Bug 461824
yum should use ngettext
Last modified: 2014-01-21 18:06:12 EST
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
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 :)
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 _().
Created attachment 322201 [details]
Patch for ngettext use in yum
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:
Install %5.5s Package(s)
Update %5.5s Package(s)
Remove %5.5s Package(s)
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 ), 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.
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)
Created attachment 322500 [details]
Patch for ngettext use in yum, ver 2
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:
Ok I added P_ as infrastructure in commit e1931cfcfe9e97062f1291e15b0c5a02752ed282.
We can add the messages when we get the Makefile stuff etc. too.
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 ***