Fix translation of KiB/s

This commit is contained in:
Calum Lind 2011-07-04 19:58:54 +01:00
commit f75ec9d484
5 changed files with 24 additions and 17 deletions

View file

@ -300,7 +300,14 @@ def fspeed(bps):
'42.1 KiB/s' '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): def fpeer(num_peers, total_peers):
""" """

View file

@ -93,15 +93,15 @@ class StatusBars(component.Component):
if self.config["max_connections_global"] > -1: if self.config["max_connections_global"] > -1:
self.bottombar += " (%s)" % self.config["max_connections_global"] self.bottombar += " (%s)" % self.config["max_connections_global"]
self.bottombar += " D: %s/s" % self.download self.bottombar += " D: %s" % self.download
if self.config["max_download_speed"] > -1: if self.config["max_download_speed"] > -1:
self.bottombar += " (%s KiB/s)" % self.config["max_download_speed"] self.bottombar += " (%s " % self.config["max_download_speed"] + _("KiB/s") + ")"
self.bottombar += " U: %s/s" % self.upload self.bottombar += " U: %s" % self.upload
if self.config["max_upload_speed"] > -1: if self.config["max_upload_speed"] > -1:
self.bottombar += " (%s KiB/s)" % self.config["max_upload_speed"] self.bottombar += " (%s " % self.config["max_upload_speed"] + _("KiB/s") + ")"
if self.config["dht"]: if self.config["dht"]:
self.bottombar += " DHT: %s" % self.dht self.bottombar += " " + _("DHT") + ": %s" % self.dht

View file

@ -453,11 +453,11 @@ class MenuBar(component.Component):
other_dialog_info = { other_dialog_info = {
"menuitem_down_speed": ( "menuitem_down_speed": (
_("Set Maximum Download Speed"), _("Set Maximum Download Speed"),
"KiB/s", None, "downloading.svg", -1.0 _("KiB/s"), None, "downloading.svg", -1.0
), ),
"menuitem_up_speed": ( "menuitem_up_speed": (
_("Set Maximum Upload Speed"), _("Set Maximum Upload Speed"),
"KiB/s", None, "seeding.svg", -1.0 _("KiB/s"), None, "seeding.svg", -1.0
), ),
"menuitem_max_connections": ( "menuitem_max_connections": (
_("Set Maximum Connections"), "", gtk.STOCK_NETWORK, None, -1 _("Set Maximum Connections"), "", gtk.STOCK_NETWORK, None, -1

View file

@ -64,7 +64,7 @@ def fpcnt(value):
def fspeed(value, max_value=-1): def fspeed(value, max_value=-1):
if 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: else:
return deluge.common.fspeed(value) return deluge.common.fspeed(value)

View file

@ -120,9 +120,9 @@ class StatusBar(component.Component):
self.max_connections = -1 self.max_connections = -1
self.num_connections = 0 self.num_connections = 0
self.max_download_speed = -1.0 self.max_download_speed = -1.0
self.download_rate = 0.0 self.download_rate = ""
self.max_upload_speed = -1.0 self.max_upload_speed = -1.0
self.upload_rate = 0.0 self.upload_rate = ""
self.dht_nodes = 0 self.dht_nodes = 0
self.dht_status = False self.dht_status = False
self.health = False self.health = False
@ -311,8 +311,8 @@ class StatusBar(component.Component):
self.remove_item(self.dht_item) self.remove_item(self.dht_item)
def _on_get_session_status(self, status): def _on_get_session_status(self, status):
self.download_rate = deluge.common.fsize(status["payload_download_rate"]) self.download_rate = deluge.common.fspeed(status["payload_download_rate"])
self.upload_rate = deluge.common.fsize(status["payload_upload_rate"]) self.upload_rate = deluge.common.fspeed(status["payload_upload_rate"])
self.download_protocol_rate = (status["download_rate"] - status["payload_download_rate"]) / 1024 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.upload_protocol_rate = (status["upload_rate"] - status["payload_upload_rate"]) / 1024
self.update_download_label() self.update_download_label()
@ -355,9 +355,9 @@ class StatusBar(component.Component):
def update_download_label(self): def update_download_label(self):
# Set the download speed label # Set the download speed label
if self.max_download_speed <= 0: if self.max_download_speed <= 0:
label_string = "%s/s" % self.download_rate label_string = self.download_rate
else: else:
label_string = "%s/s (%s %s)" % ( label_string = "%s (%s %s)" % (
self.download_rate, self.max_download_speed, _("KiB/s")) self.download_rate, self.max_download_speed, _("KiB/s"))
self.download_item.set_text(label_string) self.download_item.set_text(label_string)
@ -365,9 +365,9 @@ class StatusBar(component.Component):
def update_upload_label(self): def update_upload_label(self):
# Set the upload speed label # Set the upload speed label
if self.max_upload_speed <= 0: if self.max_upload_speed <= 0:
label_string = "%s/s" % self.upload_rate label_string = self.upload_rate
else: else:
label_string = "%s/s (%s %s)" % ( label_string = "%s (%s %s)" % (
self.upload_rate, self.max_upload_speed, _("KiB/s")) self.upload_rate, self.max_upload_speed, _("KiB/s"))
self.upload_item.set_text(label_string) self.upload_item.set_text(label_string)