summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Heinlein <sebi@sebi-pc>2006-09-27 00:21:17 +0200
committerSebastian Heinlein <sebi@sebi-pc>2006-09-27 00:21:17 +0200
commit84593d761ff3e297753111923e621dfaf9c9ff77 (patch)
treeeeece334e32181c7454a1e6b38df985a85c79480
parent958de6edfbf38390aa6ee613c9d1d1d70bd5fcb5 (diff)
downloadpython-apt-84593d761ff3e297753111923e621dfaf9c9ff77.tar.gz
* move the humanize_size method to common.utils
* make the strings in the download progress less cryptic for the translators - fix #62494 * Remove the "unkown speed" - just don't display any
-rw-r--r--UpdateManager/Common/utils.py17
-rw-r--r--UpdateManager/GtkProgress.py13
-rw-r--r--UpdateManager/UpdateManager.py23
3 files changed, 28 insertions, 25 deletions
diff --git a/UpdateManager/Common/utils.py b/UpdateManager/Common/utils.py
index 099cbfed..95440e44 100644
--- a/UpdateManager/Common/utils.py
+++ b/UpdateManager/Common/utils.py
@@ -21,3 +21,20 @@ def error(parent, summary, message):
res = d.run()
d.destroy()
return
+
+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)
diff --git a/UpdateManager/GtkProgress.py b/UpdateManager/GtkProgress.py
index 54f60384..cdc761fc 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..2bb95b2f 100644
--- a/UpdateManager/UpdateManager.py
+++ b/UpdateManager/UpdateManager.py
@@ -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 """
@@ -610,7 +593,7 @@ class UpdateManager(SimpleGladeApp):
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)))
+ humanize_size(self.dl_size)))
def update_count(self):
"""activate or disable widgets and show dialog texts correspoding to
@@ -633,7 +616,7 @@ class UpdateManager(SimpleGladeApp):
"You can install %s updates",
num_updates) % \
num_updates + "</b></big>"
- text_download = _("Download size: %s") % self.humanize_size(self.dl_size)
+ 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()
@@ -828,7 +811,7 @@ class UpdateManager(SimpleGladeApp):
else:
contents += _("Version %s") % pkg.candidateVersion
#TRANSLATORS: the b stands for Bytes
- contents += " " + _("(Size: %s)") % self.humanize_size(pkg.packageSize)
+ contents += " " + _("(Size: %s)") % humanize_size(pkg.packageSize)
contents += "</small>"
self.store.append([contents, pkg.name, pkg])