Refactor translation code in GTK torrent and filtertree views
This commit is contained in:
parent
1a0ca9edbe
commit
f7888757aa
|
@ -63,32 +63,20 @@ TRACKER_PIX = {
|
||||||
"Error": "tracker_warning",
|
"Error": "tracker_warning",
|
||||||
}
|
}
|
||||||
|
|
||||||
def _(message): return message
|
TR_LABEL = {
|
||||||
|
|
||||||
TRANSLATE = {
|
|
||||||
"state": _("States"),
|
|
||||||
"tracker_host": _("Trackers"),
|
|
||||||
"label": _("Labels"),
|
"label": _("Labels"),
|
||||||
"owner": _("Owner"),
|
"owner": _("Owner"),
|
||||||
"All": _("All"),
|
"All": _("All"),
|
||||||
|
"Active": _("Active"),
|
||||||
|
"Allocating": _("Allocating"),
|
||||||
|
"Checking": _("Checking"),
|
||||||
"Downloading": _("Downloading"),
|
"Downloading": _("Downloading"),
|
||||||
"Seeding": _("Seeding"),
|
"Seeding": _("Seeding"),
|
||||||
"Paused": _("Paused"),
|
"Paused": _("Paused"),
|
||||||
"Checking": _("Checking"),
|
|
||||||
"Queued": _("Queued"),
|
|
||||||
"Error": _("Error"),
|
"Error": _("Error"),
|
||||||
"Active": _("Active"),
|
"Queued": _("Queued"),
|
||||||
"none": _("None"),
|
|
||||||
"no_label": _("No Label"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
del _
|
|
||||||
|
|
||||||
def _t(text):
|
|
||||||
if text in TRANSLATE:
|
|
||||||
text = TRANSLATE[text]
|
|
||||||
return _(text)
|
|
||||||
|
|
||||||
FILTER_COLUMN = 5
|
FILTER_COLUMN = 5
|
||||||
|
|
||||||
#sidebar-treeview
|
#sidebar-treeview
|
||||||
|
@ -166,7 +154,7 @@ class FilterTreeView(component.Component):
|
||||||
self.filters = {}
|
self.filters = {}
|
||||||
|
|
||||||
#initial order of state filter:
|
#initial order of state filter:
|
||||||
self.cat_nodes["state"] = self.treestore.append(None, ["cat", "state", _t("State"), 0, None, False])
|
self.cat_nodes["state"] = self.treestore.append(None, ["cat", "state", _("States"), 0, None, False])
|
||||||
self.update_row("state", "All" , 0)
|
self.update_row("state", "All" , 0)
|
||||||
self.update_row("state", "Downloading" , 0)
|
self.update_row("state", "Downloading" , 0)
|
||||||
self.update_row("state", "Seeding" , 0)
|
self.update_row("state", "Seeding" , 0)
|
||||||
|
@ -174,7 +162,7 @@ class FilterTreeView(component.Component):
|
||||||
self.update_row("state", "Paused" , 0)
|
self.update_row("state", "Paused" , 0)
|
||||||
self.update_row("state", "Queued" , 0)
|
self.update_row("state", "Queued" , 0)
|
||||||
|
|
||||||
self.cat_nodes["tracker_host"] = self.treestore.append(None, ["cat", "tracker_host", _t("Trackers"), 0, None, False])
|
self.cat_nodes["tracker_host"] = self.treestore.append(None, ["cat", "tracker_host", _("Trackers"), 0, None, False])
|
||||||
self.update_row("tracker_host", "All" , 0)
|
self.update_row("tracker_host", "All" , 0)
|
||||||
self.update_row("tracker_host", "Error" , 0)
|
self.update_row("tracker_host", "Error" , 0)
|
||||||
self.update_row("tracker_host", "" , 0)
|
self.update_row("tracker_host", "" , 0)
|
||||||
|
@ -196,7 +184,7 @@ class FilterTreeView(component.Component):
|
||||||
#create missing cat_nodes
|
#create missing cat_nodes
|
||||||
for cat in filter_items:
|
for cat in filter_items:
|
||||||
if not cat in self.cat_nodes:
|
if not cat in self.cat_nodes:
|
||||||
self.cat_nodes[cat] = self.treestore.append(None, ["cat", cat, _t(cat), 0, None, False])
|
self.cat_nodes[cat] = self.treestore.append(None, ["cat", cat, TR_LABEL.get(cat, _(cat)), 0, None, False])
|
||||||
|
|
||||||
#update rows
|
#update rows
|
||||||
visible_filters = []
|
visible_filters = []
|
||||||
|
@ -238,11 +226,11 @@ class FilterTreeView(component.Component):
|
||||||
|
|
||||||
if label == "":
|
if label == "":
|
||||||
if cat == "tracker_host":
|
if cat == "tracker_host":
|
||||||
label = _t("none")
|
label = _("None")
|
||||||
elif cat == "label":
|
elif cat == "label":
|
||||||
label = _t("no_label")
|
label = _("No Label")
|
||||||
elif cat in ["state", "tracker_host", "label"]:
|
elif cat in ["state", "tracker_host", "label"]:
|
||||||
label = _t(value)
|
label = TR_LABEL.get(value, _(value))
|
||||||
|
|
||||||
row = self.treestore.append(self.cat_nodes[cat],[cat, value, label, count , pix, True])
|
row = self.treestore.append(self.cat_nodes[cat],[cat, value, label, count , pix, True])
|
||||||
self.filters[(cat, value)] = row
|
self.filters[(cat, value)] = row
|
||||||
|
|
|
@ -74,23 +74,6 @@ ICON_STATE = {
|
||||||
"Checking Resume Data": icon_checking
|
"Checking Resume Data": icon_checking
|
||||||
}
|
}
|
||||||
|
|
||||||
def _(message): return message
|
|
||||||
|
|
||||||
TRANSLATE = {
|
|
||||||
"Downloading": _("Downloading"),
|
|
||||||
"Seeding": _("Seeding"),
|
|
||||||
"Paused": _("Paused"),
|
|
||||||
"Checking": _("Checking"),
|
|
||||||
"Queued": _("Queued"),
|
|
||||||
"Error": _("Error"),
|
|
||||||
}
|
|
||||||
|
|
||||||
del _
|
|
||||||
|
|
||||||
def _t(text):
|
|
||||||
if text in TRANSLATE:
|
|
||||||
text = TRANSLATE[text]
|
|
||||||
return _(text)
|
|
||||||
|
|
||||||
def cell_data_statusicon(column, cell, model, row, data):
|
def cell_data_statusicon(column, cell, model, row, data):
|
||||||
"""Display text with an icon"""
|
"""Display text with an icon"""
|
||||||
|
@ -148,9 +131,10 @@ def cell_data_progress(column, cell, model, row, data):
|
||||||
if cell.get_property("value") != value:
|
if cell.get_property("value") != value:
|
||||||
cell.set_property("value", value)
|
cell.set_property("value", value)
|
||||||
|
|
||||||
textstr = _t(state_str)
|
# Marked for translate states text are in filtertreeview
|
||||||
|
textstr = _(state_str)
|
||||||
if state_str != "Seeding" and value < 100:
|
if state_str != "Seeding" and value < 100:
|
||||||
textstr = textstr + " %.2f%%" % value
|
textstr = "%s %.2f%%" % (textstr, value)
|
||||||
if cell.get_property("text") != textstr:
|
if cell.get_property("text") != textstr:
|
||||||
cell.set_property("text", textstr)
|
cell.set_property("text", textstr)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue