From 24bf682955918bc04c92b1810ce22e6b1a305778 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 13 Jun 2011 20:44:30 -0600 Subject: [PATCH] Fix #796790 (Condition in coloring not translated) --- src/calibre/gui2/preferences/coloring.py | 27 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/calibre/gui2/preferences/coloring.py b/src/calibre/gui2/preferences/coloring.py index b3c7873b45..3b581be701 100644 --- a/src/calibre/gui2/preferences/coloring.py +++ b/src/calibre/gui2/preferences/coloring.py @@ -22,11 +22,7 @@ from calibre.library.coloring import (Rule, conditionable_columns, class ConditionEditor(QWidget): # {{{ - def __init__(self, fm, parent=None): - QWidget.__init__(self, parent) - self.fm = fm - - self.action_map = { + ACTION_MAP = { 'bool' : ( (_('is true'), 'is true',), (_('is false'), 'is false'), @@ -61,10 +57,17 @@ class ConditionEditor(QWidget): # {{{ (_('is set'), 'is set'), (_('is not set'), 'is not set'), ), - } + } - for x in ('float', 'rating', 'datetime'): - self.action_map[x] = self.action_map['int'] + for x in ('float', 'rating', 'datetime'): + 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.setLayout(l) @@ -446,9 +449,15 @@ class RulesModel(QAbstractListModel): # {{{ def condition_to_html(self, 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 ( _('
  • If the %s column %s value: %s') % - (c, a, prepare_string_for_xml(v))) + (c, action_name, prepare_string_for_xml(v))) # }}}