Index: genshi/filters/i18n.py =================================================================== --- genshi/filters/i18n.py (revision 1238) +++ genshi/filters/i18n.py (working copy) @@ -1041,7 +1041,11 @@ while parts: order, string = parts.pop(0) - events = self.events[order].pop(0) + events = self.events[order] + if events: + events = events.pop(0) + else: + events = [(None, -1, -1)] parts_counter[order].pop() for event in events: Index: genshi/filters/tests/i18n.py =================================================================== --- genshi/filters/tests/i18n.py (revision 1238) +++ genshi/filters/tests/i18n.py (working copy) @@ -906,7 +906,19 @@ """

""", tmpl.generate(first="FIRST", second="SECOND").render()) + def test_translate_i18n_msg_ticket_404_regression(self): + tmpl = MarkupTemplate(""" +

text $name

+ """) + gettext = lambda s: u'head [1:%(name)s] tail' + translator = Translator(gettext) + translator.setup(tmpl) + self.assertEqual(""" +

head NAME tail

+ """, tmpl.generate(name='NAME').render()) + class ChooseDirectiveTestCase(unittest.TestCase): def test_translate_i18n_choose_as_attribute(self):