Fix translation of KiB/s

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

View File

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

View File

@ -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()

View File

@ -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)
}

View File

@ -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)

View File

@ -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)