Fix #796790 (Condition in coloring not translated)

This commit is contained in:
Kovid Goyal 2011-06-13 20:44:30 -06:00
parent 1ba097768d
commit 24bf682955

View File

@ -22,11 +22,7 @@ from calibre.library.coloring import (Rule, conditionable_columns,
class ConditionEditor(QWidget): # {{{ class ConditionEditor(QWidget): # {{{
def __init__(self, fm, parent=None): ACTION_MAP = {
QWidget.__init__(self, parent)
self.fm = fm
self.action_map = {
'bool' : ( 'bool' : (
(_('is true'), 'is true',), (_('is true'), 'is true',),
(_('is false'), 'is false'), (_('is false'), 'is false'),
@ -64,7 +60,14 @@ class ConditionEditor(QWidget): # {{{
} }
for x in ('float', 'rating', 'datetime'): for x in ('float', 'rating', 'datetime'):
self.action_map[x] = self.action_map['int'] ACTION_MAP[x] = ACTION_MAP['int']
def __init__(self, fm, parent=None):
QWidget.__init__(self, parent)
self.fm = fm
self.action_map = self.ACTION_MAP
self.l = l = QGridLayout(self) self.l = l = QGridLayout(self)
self.setLayout(l) self.setLayout(l)
@ -446,9 +449,15 @@ class RulesModel(QAbstractListModel): # {{{
def condition_to_html(self, condition): def condition_to_html(self, condition):
c, a, v = condition c, a, v = condition
action_name = a
for actions in ConditionEditor.ACTION_MAP.itervalues():
for trans, ac in actions:
if ac == a:
action_name = trans
return ( return (
_('<li>If the <b>%s</b> column <b>%s</b> value: <b>%s</b>') % _('<li>If the <b>%s</b> column <b>%s</b> value: <b>%s</b>') %
(c, a, prepare_string_for_xml(v))) (c, action_name, prepare_string_for_xml(v)))
# }}} # }}}