diff options
author | Matt Wilson <msw@redhat.com> | 2002-02-04 17:46:57 +0000 |
---|---|---|
committer | Matt Wilson <msw@redhat.com> | 2002-02-04 17:46:57 +0000 |
commit | c17fe085b1ac1b1f1773f01372e4432d87c2cf2b (patch) | |
tree | 94c21cad23ba7bbf441a77e9307fd462040f5175 | |
parent | 75fdeea80d4ee466bff34bf3b77501d99b408d78 (diff) | |
download | anaconda-c17fe085b1ac1b1f1773f01372e4432d87c2cf2b.tar.gz anaconda-c17fe085b1ac1b1f1773f01372e4432d87c2cf2b.tar.xz anaconda-c17fe085b1ac1b1f1773f01372e4432d87c2cf2b.zip |
fixed #59274, handling gzipped mo files. Also made a unicode mode and a non-unicode mode so text mode works again. Fixed RPM summaries and descriptions in progress and indiv. package selection
-rw-r--r-- | iw/package_gui.py | 5 | ||||
-rw-r--r-- | iw/progress_gui.py | 2 | ||||
-rw-r--r-- | splashscreen.py | 4 | ||||
-rw-r--r-- | translate.py | 38 |
4 files changed, 33 insertions, 16 deletions
diff --git a/iw/package_gui.py b/iw/package_gui.py index f26854145..0ff47e0f7 100644 --- a/iw/package_gui.py +++ b/iw/package_gui.py @@ -26,7 +26,7 @@ from iw_gui import * from string import * from thread import * from examine_gui import * -from translate import _, N_ +from translate import _, N_, utf8 def queryUpgradeContinue(intf): @@ -183,6 +183,7 @@ class IndividualPackageSelectionWindow (InstallWindow): desc = replace (header[rpm.RPMTAG_DESCRIPTION], "\n\n", "\x00") desc = replace (desc, "\n", " ") desc = replace (desc, "\x00", "\n\n") + desc = utf8(desc) return desc def make_group_list(self, hdList, comps, displayBase = 0): @@ -197,7 +198,7 @@ class IndividualPackageSelectionWindow (InstallWindow): for key in hdList.packages.keys(): header = hdList.packages[key] - group = header[rpm.RPMTAG_GROUP] + group = utf8(header[rpm.RPMTAG_GROUP]) toplevel = string.split(group, '/')[0] # make sure the dictionary item exists for group and toplevel diff --git a/iw/progress_gui.py b/iw/progress_gui.py index 23edb0842..821ab89a3 100644 --- a/iw/progress_gui.py +++ b/iw/progress_gui.py @@ -125,7 +125,7 @@ class InstallProgressWindow (InstallWindow): if len (size) > 3: size = size [0:len(size) - 3] + ',' + size[len(size) - 3:] self.curPackage["size"].set_text (_("%s KBytes") % size) - summary = header[rpm.RPMTAG_SUMMARY] + summary = utf8(header[rpm.RPMTAG_SUMMARY]) if (summary == None): summary = "(none)" self.curPackage["summary"].set_text (summary) diff --git a/splashscreen.py b/splashscreen.py index ca994e439..3c01eaed6 100644 --- a/splashscreen.py +++ b/splashscreen.py @@ -19,6 +19,10 @@ os.environ["GNOME_DISABLE_CRASH_DIALOG"] = "1" import gtk from flags import flags +from translate import cat + +# for GTK+ 2.0 +cat.setunicode(1) splashwindow = None diff --git a/translate.py b/translate.py index 69daadcf0..29d57ca40 100644 --- a/translate.py +++ b/translate.py @@ -16,25 +16,26 @@ import gettext import iconv import os +import gzread class i18n: - def __init__(self, langs=None): + def __init__(self, langs=None, unicode=0): + self.unicode = unicode if langs: self.langs = langs else: self.langs = ['C'] mofile = None + searchpath = ('po/%s.mo', + '/usr/share/locale/%s/LC_MESSAGES/anaconda.mo') for lang in self.langs: - try: - mofile = open('/usr/share/locale/%s/LC_MESSAGES/anaconda.mo' - % (lang), 'rb') - except IOError: + for path in searchpath: try: - mofile = open('po/%s.mo' % (lang,), 'rb') + mofile = gzread.open(path % (lang)) except IOError: pass - if mofile: - break + if mofile: + break if not mofile: self.cat = None self.iconv = iconv.open('utf-8', 'iso-8859-1') @@ -43,15 +44,21 @@ class i18n: self.cat = gettext.GNUTranslations(mofile) try: self.iconv = iconv.open('utf-8', self.cat.charset()) - print 'unable to translate from', self.cat.charset(), 'to utf-8' except: + print 'unable to translate from', self.cat.charset(), 'to utf-8' self.iconv = iconv.open('utf-8', 'iso-8859-1') + def setunicode(self, value): + self.unicode = value + + def getunicode(self): + return self.unicode + def getlangs(self): return self.langs def setlangs(self, langs): - self.__init__(langs) + self.__init__(langs, self.unicode) def utf8(self, string): try: @@ -60,9 +67,14 @@ class i18n: return string def gettext(self, string): - if not self.cat: - return self.utf8(string) - return self.utf8(self.cat.gettext(string)) + if self.unicode: + if not self.cat: + return self.utf8(string) + return self.utf8(self.cat.gettext(string)) + else: + if not self.cat: + return string + return self.cat.gettext(string) def N_(str): return str |