]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Only write unique comments, no duplicates.
authorPedro Algarvio <pedro@algarvio.me>
Fri, 20 Jul 2007 14:22:50 +0000 (14:22 +0000)
committerPedro Algarvio <pedro@algarvio.me>
Fri, 20 Jul 2007 14:22:50 +0000 (14:22 +0000)
babel/messages/catalog.py
babel/messages/pofile.py

index a68605f576b11bb280b52cee5989a7f84872c763..a177e81647f14d6c7b0c30969fc8d3153ebda385 100644 (file)
@@ -66,8 +66,8 @@ class Message(object):
             self.flags.add('python-format')
         else:
             self.flags.discard('python-format')
-        self.auto_comments = list(auto_comments)
-        self.user_comments = list(user_comments)
+        self.auto_comments = list(set(auto_comments))
+        self.user_comments = list(set(user_comments))
         if isinstance(previous_id, basestring):
             self.previous_id = [previous_id]
         else:
@@ -517,11 +517,11 @@ class Catalog(object):
 
     def check(self):
         """Run various validation checks on the translations in the catalog.
-        
+
         For every message which fails validation, this method yield a
         ``(message, errors)`` tuple, where ``message`` is the `Message` object
         and ``errors`` is a sequence of `TranslationError` objects.
-        
+
         :rtype: ``iterator``
         """
         checkers = []
index 951bd0dd5bf2eca76789da19979f40c4f81f16af..3e7d0fe8d2d0d5d4c3aec7d55054d1710bc30c89 100644 (file)
@@ -151,7 +151,7 @@ def read_po(fileobj, locale=None, domain=None, ignore_obsolete=False):
         else:
             string = denormalize(translations[0][1])
         message = Message(msgid, string, list(locations), set(flags),
-                          list(auto_comments), list(user_comments),
+                          list(set(auto_comments)), list(set(user_comments)),
                           lineno=offset[0] + 1)
         if obsolete[0]:
             if not ignore_obsolete:
@@ -408,9 +408,9 @@ def write_po(fileobj, catalog, width=76, no_location=False, omit_header=False,
                 comment_header = u'\n'.join(lines) + u'\n'
             _write(comment_header)
 
-        for comment in message.user_comments:
+        for comment in list(set(message.user_comments)):
             _write_comment(comment)
-        for comment in message.auto_comments:
+        for comment in list(set(message.auto_comments)):
             _write_comment(comment, prefix='.')
 
         if not no_location:
@@ -433,7 +433,7 @@ def write_po(fileobj, catalog, width=76, no_location=False, omit_header=False,
 
     if not ignore_obsolete:
         for message in catalog.obsolete.values():
-            for comment in message.user_comments:
+            for comment in list(set(message.user_comments)):
                 _write_comment(comment)
             _write_message(message, prefix='#~ ')
             _write('\n')