Fix translation of KiB/s

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

View File

@ -300,7 +300,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):
"""

View File

@ -93,15 +93,15 @@ class StatusBars(component.Component):
if self.config["max_connections_global"] > -1:
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:
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:
self.bottombar += " (%s KiB/s)" % self.config["max_upload_speed"]
self.bottombar += " (%s " % self.config["max_upload_speed"] + _("KiB/s") + ")"
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 = {
"menuitem_down_speed": (
_("Set Maximum Download Speed"),
"KiB/s", None, "downloading.svg", -1.0
_("KiB/s"), None, "downloading.svg", -1.0
),
"menuitem_up_speed": (
_("Set Maximum Upload Speed"),
"KiB/s", None, "seeding.svg", -1.0
_("KiB/s"), None, "seeding.svg", -1.0
),
"menuitem_max_connections": (
_("Set Maximum Connections"), "", gtk.STOCK_NETWORK, None, -1

View File

@ -64,7 +64,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)

View File

@ -120,9 +120,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
@ -311,8 +311,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()
@ -355,9 +355,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)
@ -365,9 +365,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)