mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-12 04:24:27 +00:00
[GTKUI] [WEBUI] Add tracker_status translation to UIs
This commit is contained in:
parent
0b4627be8a
commit
48cedf635f
@ -56,6 +56,21 @@ from deluge.common import utf8_encoded, path_join
|
||||
from deluge.log import LOG as log
|
||||
import deluge.configmanager
|
||||
|
||||
|
||||
# Dummy translation list so tracker status is translatable.
|
||||
def _(message):
|
||||
return message
|
||||
|
||||
|
||||
TRACKER_STATUS_TRANSLATION = [
|
||||
_('Error'),
|
||||
_('Warning'),
|
||||
_('Announce OK'),
|
||||
_('Announce Sent')
|
||||
]
|
||||
del _
|
||||
|
||||
|
||||
class TorrentInfo(object):
|
||||
"""
|
||||
Collects information about a torrent file.
|
||||
|
@ -40,9 +40,11 @@ import gtk, gtk.glade
|
||||
from deluge.ui.client import client
|
||||
import deluge.component as component
|
||||
import deluge.common
|
||||
from deluge.ui.common import TRACKER_STATUS_TRANSLATION
|
||||
from deluge.ui.gtkui.torrentdetails import Tab
|
||||
from deluge.log import LOG as log
|
||||
|
||||
|
||||
def fpeer_sized(first, second):
|
||||
return "%s (%s)" % (deluge.common.fsize(first), deluge.common.fsize(second))
|
||||
|
||||
@ -63,6 +65,17 @@ def fspeed(value, max_value=-1):
|
||||
else:
|
||||
return deluge.common.fspeed(value)
|
||||
|
||||
def ftranslate(text):
|
||||
if text in TRACKER_STATUS_TRANSLATION:
|
||||
text = _(text)
|
||||
elif text:
|
||||
for status in TRACKER_STATUS_TRANSLATION:
|
||||
if status in text:
|
||||
text = text.replace(status, _(status))
|
||||
break
|
||||
return text
|
||||
|
||||
|
||||
class StatusTab(Tab):
|
||||
def __init__(self):
|
||||
Tab.__init__(self)
|
||||
@ -85,7 +98,7 @@ class StatusTab(Tab):
|
||||
(glade.get_widget("summary_peers"), deluge.common.fpeer, ("num_peers", "total_peers")),
|
||||
(glade.get_widget("summary_eta"), deluge.common.ftime, ("eta",)),
|
||||
(glade.get_widget("summary_share_ratio"), fratio, ("ratio",)),
|
||||
(glade.get_widget("summary_tracker_status"), None, ("tracker_status",)),
|
||||
(glade.get_widget("summary_tracker_status"), ftranslate, ("tracker_status",)),
|
||||
(glade.get_widget("summary_next_announce"), deluge.common.ftime, ("next_announce",)),
|
||||
(glade.get_widget("summary_active_time"), deluge.common.ftime, ("active_time",)),
|
||||
(glade.get_widget("summary_seed_time"), deluge.common.ftime, ("seeding_time",)),
|
||||
|
@ -119,6 +119,12 @@ GetText.add('Allow Remote Connections', '${escape(_("Allow Remote Connections"))
|
||||
// InterfacePage.js:78
|
||||
GetText.add('Allow the use of multiple filters at once', '${escape(_("Allow the use of multiple filters at once"))}')
|
||||
|
||||
// StatusTab.js:119
|
||||
GetText.add('Announce OK', '${escape(_("Announce OK"))}')
|
||||
|
||||
// StatusTab.js:120
|
||||
GetText.add('Announce Sent', '${escape(_("Announce Sent"))}')
|
||||
|
||||
// OptionsTab.js:347, PreferencesWindow.js:107
|
||||
GetText.add('Apply', '${escape(_("Apply"))}')
|
||||
|
||||
@ -296,7 +302,7 @@ GetText.add('Encrypt entire stream', '${escape(_("Encrypt entire stream"))}')
|
||||
// EncryptionPage.js:41
|
||||
GetText.add('Encryption', '${escape(_("Encryption"))}')
|
||||
|
||||
// ConnectionManager.js:316, ConnectionManager.js:372, AddConnectionWindow.js:103, UrlWindow.js:116, FileWindow.js:103, AddWindow.js:211
|
||||
// ConnectionManager.js:316, ConnectionManager.js:372, AddConnectionWindow.js:103, StatusTab.js:117, UrlWindow.js:116, FileWindow.js:103, AddWindow.js:211
|
||||
GetText.add('Error', '${escape(_("Error"))}')
|
||||
|
||||
// Menus.js:323
|
||||
@ -830,6 +836,9 @@ GetText.add('Username', '${escape(_("Username"))}')
|
||||
// ConnectionManager.js:90
|
||||
GetText.add('Version', '${escape(_("Version"))}')
|
||||
|
||||
// StatusTab.js:118
|
||||
GetText.add('Warning', '${escape(_("Warning"))}')
|
||||
|
||||
// ConnectionManager.js:285
|
||||
GetText.add('We recommend changing the default password.<br><br>Would you like to change it now?', '${escape(_("We recommend changing the default password.<br><br>Would you like to change it now?"))}')
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*!
|
||||
* Deluge.details.StatusTab.js
|
||||
*
|
||||
*
|
||||
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -38,19 +38,19 @@ Ext.ns('Deluge.details');
|
||||
Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
|
||||
title: _('Status'),
|
||||
autoScroll: true,
|
||||
|
||||
|
||||
onRender: function(ct, position) {
|
||||
Deluge.details.StatusTab.superclass.onRender.call(this, ct, position);
|
||||
|
||||
|
||||
this.progressBar = this.add({
|
||||
xtype: 'progress',
|
||||
cls: 'x-deluge-status-progressbar'
|
||||
});
|
||||
|
||||
|
||||
this.status = this.add({
|
||||
cls: 'x-deluge-status',
|
||||
id: 'deluge-details-status',
|
||||
|
||||
|
||||
border: false,
|
||||
width: 1000,
|
||||
listeners: {
|
||||
@ -67,14 +67,14 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
clear: function() {
|
||||
this.progressBar.updateProgress(0, ' ');
|
||||
for (var k in this.fields) {
|
||||
this.fields[k].innerHTML = '';
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
update: function(torrentId) {
|
||||
if (!this.fields) this.getFields();
|
||||
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Status, {
|
||||
@ -82,14 +82,14 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
|
||||
scope: this
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
onPanelUpdate: function(el, response) {
|
||||
this.fields = {};
|
||||
Ext.each(Ext.query('dd', this.status.body.dom), function(field) {
|
||||
this.fields[field.className] = field;
|
||||
}, this);
|
||||
},
|
||||
|
||||
|
||||
onRequestComplete: function(status) {
|
||||
seeders = status.total_seeds > -1 ? status.num_seeds + ' (' + status.total_seeds + ')' : status.num_seeds
|
||||
peers = status.total_peers > -1 ? status.num_peers + ' (' + status.total_peers + ')' : status.num_peers
|
||||
@ -113,9 +113,22 @@ 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') + ')';
|
||||
|
||||
|
||||
for (var field in this.fields) {
|
||||
this.fields[field].innerHTML = data[field];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user