Bug 251891 - yum info does not translate descriptions of remote packages
yum info does not translate descriptions of remote packages
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: yum (Show other bugs)
7
All Linux
low Severity medium
: ---
: ---
Assigned To: Jeremy Katz
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-08-13 06:20 EDT by Stepan Kasal
Modified: 2014-01-21 17:59 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-09-13 15:40:57 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)

  None (edit)
Description Stepan Kasal 2007-08-13 06:20:17 EDT
When yum info lists packages from remote repositories, the summary and
description strings are not localized, though the translations are available, in
the catalogues provided by the specspo package.
Note that the summary an description fields change only infrequently, so it is
probable that the translations from previous specspo are still usable.

An example:
on an F7 system with lang cs_CZ.UTF-8, "yum install pam-devel" returns two
descriptions of the very same version of the package: under the header
"Installed Packages," the summary and description are translated, while under
the header " " they are not.  Yum should call gettext to translate the latter.
Comment 1 Stepan Kasal 2007-08-13 06:35:24 EDT
Sorry for a typo in the original description:
[...] while under the header "Available Packages" they are not.  Yum should call
gettext to translate [them].
Comment 2 Seth Vidal 2007-08-13 09:04:54 EDT
if you just download the pam-devel package which is listed in 'Available
Packages' but you do not install it - if you run:

rpm -qpi on that package is the information there translated?
Comment 3 Jeremy Katz 2007-08-13 11:32:20 EDT
Part of the problem here is that the i18ndomains definition used by rpm to
decide what domain to use isn't exported at all, so we'd have to just go with
something hardcoded like redhat-dist, which really isn't what you want.

Something like the following will work once we can get the info from rpm...
[katzj@aglarond yum]$ git diff output.py |cat
diff --git a/output.py b/output.py
index 6973ded..33f61e2 100644
--- a/output.py
+++ b/output.py
@@ -20,6 +20,7 @@
 import sys
 import time
 import logging
+import gettext
 from i18n import _
 
 from urlgrabber.progress import TextMeter
@@ -39,6 +40,8 @@ class YumOutput:
     def __init__(self):
         self.logger = logging.getLogger("yum.cli")
         self.verbose_logger = logging.getLogger("yum.verbose.cli")
+        # FIXME: this should be dynamic and based on the rpm macro
+        self.i18ndomains = ["redhat-dist"]
     
     def printtime(self):
         months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
@@ -68,9 +71,14 @@ class YumOutput:
         
     def infoOutput(self, pkg):
         def enc(s):
-            # this sucks.  what we get back from the rpmdb
-            # are strings, but they may actually have unicode so we
-            # can't encode them
+            """Get the translated version from specspo and ensure that
+            it's actually encoded in UTF-8."""
+            if len(s) > 0:
+                for d in self.i18ndomains:
+                    t = gettext.dgettext(d, s)
+                    if t != s:
+                        s = t
+                        break
             if type(s) == unicode:
                 return s.encode("UTF-8")
             return s
Comment 4 Jeremy Katz 2007-08-13 11:53:51 EDT
https://lists.dulug.duke.edu/pipermail/rpm-maint/2007-August/000511.html is a
patch to export rpmExpand to the python bindings
Comment 5 Stepan Kasal 2007-08-16 05:42:09 EDT
(In reply to comment #2)
> if you just download the pam-devel package which is listed in 'Available
> Packages' but you do not install it - if you run:
> rpm -qpi on that package is the information there translated?

Yes.

(I removed pam-devel from my system and verified that rpm -qpi still translates
the strings using the catalogue from the specspo package.
Comment 6 Jeremy Katz 2007-09-13 15:40:57 EDT
rpm patch went in, so committed change to yum to do this

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