From 5d4c8241ea1f65cd4d80716ec06e76ff0d2fa01c Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Mon, 4 Jul 2011 19:58:54 +0100 Subject: [PATCH] Fix translation of KiB/s --- deluge/common.py | 9 ++++++++- deluge/ui/console/statusbars.py | 10 +++++----- deluge/ui/gtkui/menubar.py | 4 ++-- deluge/ui/gtkui/status_tab.py | 2 +- deluge/ui/gtkui/statusbar.py | 16 ++++++++-------- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/deluge/common.py b/deluge/common.py index 561fba02a..ed07e072b 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -311,7 +311,14 @@ def fspeed(bps): '42.1 KiB/s' """ - return '%s/s' % (fsize(bps)) + fspeed_kb = bps / 1024.0 + if fspeed_kb < 1024: + return "%.1f %s" % (fspeed_kb, _("KiB/s")) + fspeed_mb = fspeed_kb / 1024.0 + if fspeed_mb < 1024: + return "%.1f %s" % (fspeed_mb, _("MiB/s")) + fspeed_gb = fspeed_mb / 1024.0 + return "%.1f %s" % (fspeed_gb, _("GiB/s")) def fpeer(num_peers, total_peers): """ diff --git a/deluge/ui/console/statusbars.py b/deluge/ui/console/statusbars.py index 44be33cf0..342946392 100644 --- a/deluge/ui/console/statusbars.py +++ b/deluge/ui/console/statusbars.py @@ -90,17 +90,17 @@ class StatusBars(component.Component): if self.config["max_connections_global"] > -1: self.screen.bottombar += " (%s)" % self.config["max_connections_global"] - self.screen.bottombar += " D: %s/s" % self.download + self.screen.bottombar += " D: %s" % self.download if self.config["max_download_speed"] > -1: - self.screen.bottombar += " (%s KiB/s)" % self.config["max_download_speed"] + self.screen.bottombar += " (%s " % self.config["max_download_speed"] + _("KiB/s") + ")" - self.screen.bottombar += " U: %s/s" % self.upload + self.screen.bottombar += " U: %s" % self.upload if self.config["max_upload_speed"] > -1: - self.screen.bottombar += " (%s KiB/s)" % self.config["max_upload_speed"] + self.screen.bottombar += " (%s " % self.config["max_upload_speed"] + _("KiB/s") + ")" if self.config["dht"]: - self.screen.bottombar += " DHT: %s" % self.dht + self.screen.bottombar += " " + _("DHT") + ": %s" % self.dht self.screen.refresh() diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 8677ba67a..2e3ca8edc 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -433,8 +433,8 @@ class MenuBar(component.Component): } # widget: (header, type_str, image_stockid, image_filename, default) other_dialog_info = { - "menuitem_down_speed": (_("Set Maximum Download Speed"), "KiB/s", None, "downloading.svg", -1.0), - "menuitem_up_speed": (_("Set Maximum Upload Speed"), "KiB/s", None, "seeding.svg", -1.0), + "menuitem_down_speed": (_("Set Maximum Download Speed"), _("KiB/s"), None, "downloading.svg", -1.0), + "menuitem_up_speed": (_("Set Maximum Upload Speed"), _("KiB/s"), None, "seeding.svg", -1.0), "menuitem_max_connections": (_("Set Maximum Connections"), "", gtk.STOCK_NETWORK, None, -1), "menuitem_upload_slots": (_("Set Maximum Upload Slots"), "", gtk.STOCK_SORT_ASCENDING, None, -1) } diff --git a/deluge/ui/gtkui/status_tab.py b/deluge/ui/gtkui/status_tab.py index f4462a045..7ffb0079c 100644 --- a/deluge/ui/gtkui/status_tab.py +++ b/deluge/ui/gtkui/status_tab.py @@ -59,7 +59,7 @@ def fpcnt(value): def fspeed(value, max_value=-1): if max_value > -1: - return "%s [%s %s]" % (deluge.common.fspeed(value), max_value, _("KiB/s")) + return "%s (%s %s)" % (deluge.common.fspeed(value), max_value, _("KiB/s")) else: return deluge.common.fspeed(value) diff --git a/deluge/ui/gtkui/statusbar.py b/deluge/ui/gtkui/statusbar.py index a95e78b61..a187866b4 100644 --- a/deluge/ui/gtkui/statusbar.py +++ b/deluge/ui/gtkui/statusbar.py @@ -118,9 +118,9 @@ class StatusBar(component.Component): self.max_connections = -1 self.num_connections = 0 self.max_download_speed = -1.0 - self.download_rate = 0.0 + self.download_rate = "" self.max_upload_speed = -1.0 - self.upload_rate = 0.0 + self.upload_rate = "" self.dht_nodes = 0 self.dht_status = False self.health = False @@ -313,8 +313,8 @@ class StatusBar(component.Component): self.remove_item(self.dht_item) def _on_get_session_status(self, status): - self.download_rate = deluge.common.fsize(status["payload_download_rate"]) - self.upload_rate = deluge.common.fsize(status["payload_upload_rate"]) + self.download_rate = deluge.common.fspeed(status["payload_download_rate"]) + self.upload_rate = deluge.common.fspeed(status["payload_upload_rate"]) self.download_protocol_rate = (status["download_rate"] - status["payload_download_rate"]) / 1024 self.upload_protocol_rate = (status["upload_rate"] - status["payload_upload_rate"]) / 1024 self.update_download_label() @@ -357,9 +357,9 @@ class StatusBar(component.Component): def update_download_label(self): # Set the download speed label if self.max_download_speed <= 0: - label_string = "%s/s" % self.download_rate + label_string = self.download_rate else: - label_string = "%s/s (%s %s)" % ( + label_string = "%s (%s %s)" % ( self.download_rate, self.max_download_speed, _("KiB/s")) self.download_item.set_text(label_string) @@ -367,9 +367,9 @@ class StatusBar(component.Component): def update_upload_label(self): # Set the upload speed label if self.max_upload_speed <= 0: - label_string = "%s/s" % self.upload_rate + label_string = self.upload_rate else: - label_string = "%s/s (%s %s)" % ( + label_string = "%s (%s %s)" % ( self.upload_rate, self.max_upload_speed, _("KiB/s")) self.upload_item.set_text(label_string)