diff --git a/gramps/gen/filters/_genericfilter.py b/gramps/gen/filters/_genericfilter.py index a69bd3119..6fd1f55ec 100644 --- a/gramps/gen/filters/_genericfilter.py +++ b/gramps/gen/filters/_genericfilter.py @@ -380,3 +380,28 @@ def GenericFilterFactory(namespace): return GenericRepoFilter elif namespace == 'Note': return GenericNoteFilter + + +class DeferredFilter(GenericFilter): + """ + Filter class allowing for deferred translation of the filter name + """ + + def __init__(self, filter_name, person_name): + GenericFilter.__init__(self, None) + self.name_pair = [filter_name, person_name] + + def get_name(self, ulocale=glocale): + """ + return the filter name, possibly translated + + If ulocale is passed in (a :class:`.GrampsLocale`) then + the translated value will be returned instead. + + :param ulocale: allow deferred translation of strings + :type ulocale: a :class:`.GrampsLocale` instance + """ + self._ = ulocale.translation.gettext + if self.name_pair[1]: + return self._(self.name_pair[0]) % self.name_pair[1] + return self._(self.name_pair[0])