]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fixed de-pluralization bug introduced in [85] regarding the extraction of translator...
authorPedro Algarvio <pedro@algarvio.me>
Sun, 10 Jun 2007 21:14:38 +0000 (21:14 +0000)
committerPedro Algarvio <pedro@algarvio.me>
Sun, 10 Jun 2007 21:14:38 +0000 (21:14 +0000)
Added a unittest which tests the extraction of translator comments that have non-translator comments right before the comment tag.

babel/messages/extract.py
babel/messages/tests/extract.py

index be468176f16ee24eb96924790c67c72e3a19d732..2c74529eeb0ee192a93115bb6bcb76fd2a05a542 100644 (file)
@@ -296,8 +296,8 @@ def extract_python(fileobj, keywords, comment_tags, options):
             if in_translator_comments is True:
                 translator_comments.append(value[1:].strip())
                 continue
-            for comment_tags in comment_tags:
-                if comment_tags in value:
+            for comment_tag in comment_tags:
+                if comment_tag in value:
                     if in_translator_comments is not True:
                         in_translator_comments = True
                     translator_comments.append(value[1:].strip())
index 6a8672257ac47b654ec0ac3b7dba1a4338b6e03f..4dea8dbe979097bb1be574ce07daec2084f350f0 100644 (file)
@@ -39,6 +39,19 @@ msg = _(u'Foo Bar')
 # 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 test_translator_comments_with_previous_non_translator_comments(self):
+        buf = StringIO("""
+# This shouldn't be in the output
+# because it didn't start with a comment tag
+# 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])