changeset 87:f140be344563

Fixed de-pluralization bug introduced in [85] regarding the extraction of translator comments. Added a unittest which tests the extraction of translator comments that have non-translator comments right before the comment tag.
author palgarvio
date Sun, 10 Jun 2007 21:14:38 +0000
parents 8a703ecdba91
children 6da7113eaec0
files babel/messages/extract.py babel/messages/tests/extract.py
diffstat 2 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/babel/messages/extract.py
+++ b/babel/messages/extract.py
@@ -296,8 +296,8 @@
             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())
--- a/babel/messages/tests/extract.py
+++ b/babel/messages/tests/extract.py
@@ -44,6 +44,19 @@
         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])
+        self.assertEqual(['NOTE: A translation comment', 'with a second line'],
+                         messages[0][3])
 
 
 def suite():
Copyright (C) 2012-2017 Edgewall Software