diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2006-09-29 17:00:29 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2006-09-29 17:00:29 +0200 |
| commit | d74718143cd630e09ee14f5a2fb946b86266cb37 (patch) | |
| tree | 7509d730c14e38838e26acaf7e4f150837c464ed /UpdateManager | |
| parent | e40dd39c6ad5b1d29644430cdecdfc02bf674a8a (diff) | |
| parent | b9dffe7bcfab1807249821bacb8b39e83d20d5eb (diff) | |
| download | python-apt-d74718143cd630e09ee14f5a2fb946b86266cb37.tar.gz | |
* merged from glatzor
Diffstat (limited to 'UpdateManager')
| -rw-r--r-- | UpdateManager/Common/utils.py | 19 | ||||
| -rw-r--r-- | UpdateManager/GtkProgress.py | 13 | ||||
| -rw-r--r-- | UpdateManager/UpdateManager.py | 51 |
3 files changed, 44 insertions, 39 deletions
diff --git a/UpdateManager/Common/utils.py b/UpdateManager/Common/utils.py index 099cbfed..1fcd022f 100644 --- a/UpdateManager/Common/utils.py +++ b/UpdateManager/Common/utils.py @@ -1,4 +1,6 @@ import gtk +from gettext import gettext as _ +import locale def str_to_bool(str): if str == "0" or str.upper() == "FALSE": @@ -21,3 +23,20 @@ def error(parent, summary, message): res = d.run() d.destroy() return + +def humanize_size(bytes): + """ + Convert a given size in bytes to a nicer better readable unit + """ + if bytes == 0: + # TRANSLATORS: download size is 0 + return _("None") + elif bytes < 1024: + # TRANSLATORS: download size of very small updates + return _("1 KB") + elif bytes < 1024 * 1024: + # TRANSLATORS: download size of small updates, e.g. "250 KB" + return locale.format(_("%.0f KB"), bytes/1024) + else: + # TRANSLATORS: download size of updates, e.g. "2.3 MB" + return locale.format(_("%.1f MB"), bytes / 1024 / 1024) diff --git a/UpdateManager/GtkProgress.py b/UpdateManager/GtkProgress.py index 54f60384..cb635e87 100644 --- a/UpdateManager/GtkProgress.py +++ b/UpdateManager/GtkProgress.py @@ -25,6 +25,7 @@ import gtk import apt import apt_pkg from gettext import gettext as _ +from Common.utils import * # intervals of the start up progress # 3x caching and menu creation @@ -104,12 +105,14 @@ class GtkFetchProgress(apt.progress.FetchProgress): if currentItem > self.totalItems: currentItem = self.totalItems if self.currentCPS > 0: - statusText = (_("Downloading file %li of %li with %s/s" - % (currentItem, self.totalItems, - apt_pkg.SizeToStr(self.currentCPS)))) + statusText = (_("Downloading file %(current)li of %(total)li with " + "%(speed)s/s") % {"current" : currentItem, + "total" : self.totalItems, + "speed" : humanize_size(self.currentCPS)}) else: - statusText = (_("Downloading file %li of %li with unknown " - "speed") % (currentItem, self.totalItems)) + statusText = (_("Downloading file %(current)li of %(total)li") % \ + {"current" : currentItem, + "total" : self.totalItems }) self.progress.set_fraction(self.percent/100.0) self.status.set_markup("<i>%s</i>" % statusText) # TRANSLATORS: show the remaining time in a progress bar: diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index 63d0eab9..04ad107c 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -237,7 +237,7 @@ class UpdateList: ("%s-updates" % dist, "Ubuntu", _("Recommended updates"), 9), ("%s-proposed" % dist, "Ubuntu", _("Proposed updates"), 8), ("%s-backports" % dist, "Ubuntu", _("Backports"), 7), - (dist, "Ubuntu", _("Normal updates"), 6)] + (dist, "Ubuntu", _("Distribution updates"), 6)] self.pkgs = {} self.matcher = {} @@ -576,23 +576,6 @@ class UpdateManager(SimpleGladeApp): self.treeview_update.queue_draw() self.setBusy(False) - def humanize_size(self, bytes): - """ - Convert a given size in bytes to a nicer better readable unit - """ - if bytes == 0: - # TRANSLATORS: download size is 0 - return _("None") - elif bytes < 1024: - # TRANSLATORS: download size of very small updates - return _("1 KB") - elif bytes < 1024 * 1024: - # TRANSLATORS: download size of small updates, e.g. "250 KB" - return locale.format(_("%.0f KB"), bytes/1024) - else: - # TRANSLATORS: download size of updates, e.g. "2.3 MB" - return locale.format(_("%.1f MB"), bytes / 1024 / 1024) - def setBusy(self, flag): """ Show a watch cursor if the app is busy for more than 0.3 sec. Furthermore provide a loop to handle user interface events """ @@ -609,8 +592,8 @@ class UpdateManager(SimpleGladeApp): self.button_install.set_sensitive(self.cache.installCount) self.dl_size = self.cache.requiredDownload # TRANSLATORS: b stands for Bytes - self.label_downsize.set_markup(_("Download size: %s" % \ - self.humanize_size(self.dl_size))) + self.label_downsize.set_markup(_("Download size: %s") % \ + humanize_size(self.dl_size)) def update_count(self): """activate or disable widgets and show dialog texts correspoding to @@ -618,7 +601,7 @@ class UpdateManager(SimpleGladeApp): self.refresh_updates_count() num_updates = self.cache.installCount if num_updates == 0: - text_header= "<big><b>"+_("Your system is up-to-date")+"</b></big>" + text_header= "<big><b>%s</b></big>" %_("Your system is up-to-date") text_download = "" self.notebook_details.set_sensitive(False) self.treeview_update.set_sensitive(False) @@ -628,12 +611,12 @@ class UpdateManager(SimpleGladeApp): self.textview_changes.get_buffer().set_text("") self.textview_descr.get_buffer().set_text("") else: - text_header = "<big><b>" + \ - gettext.ngettext("You can install %s update", - "You can install %s updates", - num_updates) % \ - num_updates + "</b></big>" - text_download = _("Download size: %s") % self.humanize_size(self.dl_size) + text_header = "<big><b>%s</b></big>" % \ + (gettext.ngettext("You can install %s update", + "You can install %s updates", + num_updates) % \ + num_updates) + text_download = _("Download size: %s") % humanize_size(self.dl_size) self.notebook_details.set_sensitive(True) self.treeview_update.set_sensitive(True) self.button_install.grab_default() @@ -820,16 +803,16 @@ class UpdateManager(SimpleGladeApp): for pkg in self.list.pkgs[origin]: name = xml.sax.saxutils.escape(pkg.name) summary = xml.sax.saxutils.escape(pkg.summary) - contents = "<b>%s</b>\n<small>%s\n" % (name, summary) + contents = "<b>%s</b>\n<small>%s</small>" % (name, summary) if pkg.installedVersion != None: - contents += _("From version %s to %s") % \ - (pkg.installedVersion, - pkg.candidateVersion) + version = _("From version %(old_version)s to %(new_version)s") %\ + {"old_version" : pkg.installedVersion, + "new_version" : pkg.candidateVersion} else: - contents += _("Version %s") % pkg.candidateVersion + version = _("Version %s") % pkg.candidateVersion #TRANSLATORS: the b stands for Bytes - contents += " " + _("(Size: %s)") % self.humanize_size(pkg.packageSize) - contents += "</small>" + size = _("(Size: %s)") % humanize_size(pkg.packageSize) + contents = "%s\n<small>%s %s</small>" % (contents, version, size) self.store.append([contents, pkg.name, pkg]) self.update_count() |
