From 8eb2155eac26c26d7ca08231765e0524ffc3206a Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Thu, 16 Jan 2014 16:48:32 +0000 Subject: [PATCH] Remove torrent_status translations from Daemon and move to UI clients --- deluge/core/filtermanager.py | 3 +-- deluge/core/torrentmanager.py | 8 ++++---- deluge/main.py | 1 - deluge/ui/gtkui/status_tab.py | 12 ++++++++++++ deluge/ui/web/js/deluge-all/details/StatusTab.js | 13 +++++++++++++ 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/deluge/core/filtermanager.py b/deluge/core/filtermanager.py index b8e5a77a4..d4af33a4a 100644 --- a/deluge/core/filtermanager.py +++ b/deluge/core/filtermanager.py @@ -111,10 +111,9 @@ def tracker_error_filter(torrent_ids, values): filtered_torrent_ids.append(torrent_id) return filtered_torrent_ids - error_str = _("Error") + ":" # Check torrent's tracker_status for 'Error:' and return those torrent_ids for torrent_id in torrent_ids: - if error_str in tm[torrent_id].get_status(["tracker_status"])["tracker_status"]: + if "Error:" in tm[torrent_id].get_status(["tracker_status"])["tracker_status"]: filtered_torrent_ids.append(torrent_id) return filtered_torrent_ids diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 5829e910d..68ecb1a42 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -972,7 +972,7 @@ class TorrentManager(component.Component): return # Set the tracker status for the torrent - torrent.set_tracker_status(_("Announce OK")) + torrent.set_tracker_status("Announce OK") # Check to see if we got any peer information from the tracker if alert.handle.status().num_complete == -1 or \ @@ -990,7 +990,7 @@ class TorrentManager(component.Component): return # Set the tracker status for the torrent - torrent.set_tracker_status(_("Announce Sent")) + torrent.set_tracker_status("Announce Sent") def on_alert_tracker_warning(self, alert): """Alert handler for libtorrent tracker_warning_alert""" @@ -999,7 +999,7 @@ class TorrentManager(component.Component): torrent = self.torrents[str(alert.handle.info_hash())] except RuntimeError: return - tracker_status = '%s: %s' % (_("Warning"), decode_string(alert.message())) + tracker_status = 'Warning: %s' % decode_string(alert.message()) # Set the tracker status for the torrent torrent.set_tracker_status(tracker_status) @@ -1010,7 +1010,7 @@ class TorrentManager(component.Component): torrent = self.torrents[str(alert.handle.info_hash())] except RuntimeError: return - tracker_status = "%s: %s" % (_("Error"), decode_string(alert.msg)) + tracker_status = "Error: %s" % decode_string(alert.msg) torrent.set_tracker_status(tracker_status) def on_alert_storage_moved(self, alert): diff --git a/deluge/main.py b/deluge/main.py index 2a747e97f..4a3bf3746 100644 --- a/deluge/main.py +++ b/deluge/main.py @@ -140,7 +140,6 @@ def start_ui(): def start_daemon(): """Entry point for daemon script""" - deluge.common.setup_translations() if 'dev' not in deluge.common.get_version(): import warnings diff --git a/deluge/ui/gtkui/status_tab.py b/deluge/ui/gtkui/status_tab.py index a5bd5d3e9..3bcb78215 100644 --- a/deluge/ui/gtkui/status_tab.py +++ b/deluge/ui/gtkui/status_tab.py @@ -147,6 +147,18 @@ class StatusTab(Tab): else: status["is_auto_managed"]=_("Off") + translate_tracker_status = { + "Error" : _("Error"), + "Warning" : _("Warning"), + "Announce OK" : _("Announce OK"), + "Announce Sent" : _("Announce Sent") + } + for key, value in translate_tracker_status.iteritems(): + if key in status["tracker_status"]: + status["tracker_status"] = status["tracker_status"].replace(key, value, 1) + log.error(status["tracker_status"]) + break + # Update all the label widgets for widget in self.label_widgets: if widget[1] != None: diff --git a/deluge/ui/web/js/deluge-all/details/StatusTab.js b/deluge/ui/web/js/deluge-all/details/StatusTab.js index 7d0492f7f..edf897ff5 100644 --- a/deluge/ui/web/js/deluge-all/details/StatusTab.js +++ b/deluge/ui/web/js/deluge-all/details/StatusTab.js @@ -115,6 +115,19 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, { } data.auto_managed = _((status.is_auto_managed) ? 'True' : 'False'); + var translate_tracker_status = { + 'Error' : _('Error'), + 'Warning' : _('Warning'), + 'Announce OK' : _('Announce OK'), + 'Announce Sent' : _('Announce Sent') + }; + for (var key in translate_tracker_status) { + if (data.tracker_status.indexOf(key) != -1) { + data.tracker_status = data.tracker_status.replace(key, translate_tracker_status[key]); + break; + } + } + data.downloaded += ' (' + ((status.total_payload_download) ? fsize(status.total_payload_download) : '0.0 KiB') + ')'; data.uploaded += ' (' + ((status.total_payload_upload) ? fsize(status.total_payload_upload): '0.0 KiB') + ')';