def test_unicode_string_arg(self):
buf = StringIO("msg = _(u'Foo Bar')")
- messages = list(extract.extract_python(buf, ('_',), {}, []))
+ messages = list(extract.extract_python(buf, ('_',), [], {}))
self.assertEqual('Foo Bar', messages[0][2])
+ def test_comment_tag(self):
+ buf = StringIO("""
+# NOTE: A translation comment
+msg = _(u'Foo Bar')
+""")
+ messages = list(extract.extract_python(buf, ('_',), ['NOTE'], {}))
+ self.assertEqual('Foo Bar', messages[0][2])
+ self.assertEqual(['NOTE: A translation comment'], messages[0][3])
+
+ def test_comment_tag_multiline(self):
+ buf = StringIO("""
+# NOTE: A translation comment
+# with a second line
+msg = _(u'Foo Bar')
+""")
+ messages = list(extract.extract_python(buf, ('_',), ['NOTE'], {}))
+ self.assertEqual('Foo Bar', messages[0][2])
+ self.assertEqual(['NOTE: A translation comment', 'with a second line'],
+ messages[0][3])
+
def suite():
suite = unittest.TestSuite()
:rtype: ``iterator``
"""
+.. note:: Any strings in the tuples produced by this function must be either
+ ``unicode`` objects, or ``str`` objects using plain ASCII characters.
+ That means that if sources contain strings using other encodings, it
+ is the job of the extractor implementation to do the decoding to
+ ``unicode`` objects.
+
Next, you should register that function as an entry point. This requires your
``setup.py`` script to use `setuptools`_, and your package to be installed with
the necessary metadata. If that's taken care of, add something like the