From 84593d761ff3e297753111923e621dfaf9c9ff77 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Wed, 27 Sep 2006 00:21:17 +0200 Subject: * 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 --- UpdateManager/Common/utils.py | 17 +++++++++++++++++ UpdateManager/GtkProgress.py | 13 ++++++++----- UpdateManager/UpdateManager.py | 23 +++-------------------- 3 files changed, 28 insertions(+), 25 deletions(-) (limited to 'UpdateManager') 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("%s" % 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 + "" - 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 += "" self.store.append([contents, pkg.name, pkg]) -- cgit v1.2.3 From cf3decd2e830b53569e8dd9c12c2469914eb9b21 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Wed, 27 Sep 2006 00:30:46 +0200 Subject: * Make some strings translatable - seems that gettext doesn't like being part of string addition. the other one was my fault and not the one of gettext. fix #62519 and #62458 * Fix the imports and calls of human_size --- UpdateManager/Common/utils.py | 3 ++- UpdateManager/GtkProgress.py | 2 +- UpdateManager/UpdateManager.py | 16 ++++++++-------- po/POTFILES.in | 1 + 4 files changed, 12 insertions(+), 10 deletions(-) (limited to 'UpdateManager') diff --git a/UpdateManager/Common/utils.py b/UpdateManager/Common/utils.py index 95440e44..fa73b8bd 100644 --- a/UpdateManager/Common/utils.py +++ b/UpdateManager/Common/utils.py @@ -1,4 +1,5 @@ import gtk +from gettext import gettext as _ def str_to_bool(str): if str == "0" or str.upper() == "FALSE": @@ -22,7 +23,7 @@ def error(parent, summary, message): d.destroy() return -def humanize_size(self, bytes): +def humanize_size(bytes): """ Convert a given size in bytes to a nicer better readable unit """ diff --git a/UpdateManager/GtkProgress.py b/UpdateManager/GtkProgress.py index cdc761fc..cb635e87 100644 --- a/UpdateManager/GtkProgress.py +++ b/UpdateManager/GtkProgress.py @@ -25,7 +25,7 @@ import gtk import apt import apt_pkg from gettext import gettext as _ -from common.utils import * +from Common.utils import * # intervals of the start up progress # 3x caching and menu creation diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index 2bb95b2f..02a89a40 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -592,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" % \ - 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 @@ -601,7 +601,7 @@ class UpdateManager(SimpleGladeApp): self.refresh_updates_count() num_updates = self.cache.installCount if num_updates == 0: - text_header= ""+_("Your system is up-to-date")+"" + text_header= "%s" + text_header = "%s" % \ + (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) diff --git a/po/POTFILES.in b/po/POTFILES.in index b383e84c..64774c4e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ UpdateManager/fakegconf.py UpdateManager/ReleaseNotesViewer.py UpdateManager/GtkProgress.py UpdateManager/UpdateManager.py +UpdateManager/Common/utils.py data/mime/apt.xml.in data/glade/UpdateManager.glade data/glade/SoftwareProperties.glade -- cgit v1.2.3 From 2c847b09b6e124bc30872ee537151c88de3bd65c Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Wed, 27 Sep 2006 00:52:26 +0200 Subject: * Fixed a missing import * Hopefully some strings can now be translated * Wording: Normal -> Distribution updates, to better separate them from the third party updates --- UpdateManager/Common/utils.py | 1 + UpdateManager/UpdateManager.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'UpdateManager') diff --git a/UpdateManager/Common/utils.py b/UpdateManager/Common/utils.py index fa73b8bd..1fcd022f 100644 --- a/UpdateManager/Common/utils.py +++ b/UpdateManager/Common/utils.py @@ -1,5 +1,6 @@ import gtk from gettext import gettext as _ +import locale def str_to_bool(str): if str == "0" or str.upper() == "FALSE": diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index 02a89a40..0219872c 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 = {} @@ -803,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 = "%s\n%s\n" % (name, summary) + contents = "%s\n%s" % (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)") % humanize_size(pkg.packageSize) - contents += "" + size = _("(Size: %s)") % humanize_size(pkg.packageSize) + contents = "%s\n%s %s" % (contents, version, size) self.store.append([contents, pkg.name, pkg]) self.update_count() -- cgit v1.2.3 From b9dffe7bcfab1807249821bacb8b39e83d20d5eb Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Wed, 27 Sep 2006 01:01:51 +0200 Subject: * fixed some markups --- UpdateManager/UpdateManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'UpdateManager') diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index 0219872c..04ad107c 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -601,7 +601,7 @@ class UpdateManager(SimpleGladeApp): self.refresh_updates_count() num_updates = self.cache.installCount if num_updates == 0: - text_header= "%s