Mercurial > babel > old > babel-test
diff babel/messages/catalog.py @ 105:f744dd56573d
`Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
The `Generated-By` header value needed a missing `\n`.
The frontends now pass the value of `--copyright-holder` to the Catalog, and removed the `copyright_holder` arg for `write_po` left behind on [105].
Tests changed accordingly.
author | palgarvio |
---|---|
date | Thu, 14 Jun 2007 06:24:28 +0000 |
parents | 22f222e23b86 |
children | 9b22b36066f6 |
line wrap: on
line diff
--- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -35,7 +35,8 @@ class Message(object): """Representation of a single message in a catalog.""" - def __init__(self, id, string='', locations=(), flags=(), comments=()): + def __init__(self, id, string='', locations=(), flags=(), auto_comments=(), + user_comments=()): """Create the message object. :param id: the message ID, or a ``(singular, plural)`` tuple for @@ -56,7 +57,8 @@ self.flags.add('python-format') else: self.flags.discard('python-format') - self.comments = list(comments) + self.auto_comments = list(auto_comments) + self.user_comments = list(user_comments) def __repr__(self): return '<%s %r>' % (type(self).__name__, self.id) @@ -103,6 +105,7 @@ :type: `bool` """) + DEFAULT_HEADER = u"""\ # Translations template for PROJECT. # Copyright (C) YEAR COPYRIGHT HOLDER @@ -208,7 +211,7 @@ headers.append(('Content-Type', 'text/plain; charset=%s' % self.charset)) headers.append(('Content-Transfer-Encoding', '8bit')) - headers.append(('Generated-By', 'Babel %s' % VERSION)) + headers.append(('Generated-By', 'Babel %s\n' % VERSION)) return headers mime_headers = property(mime_headers, doc="""\ The MIME headers of the catalog, used for the special ``msgid ""`` entry. @@ -373,7 +376,8 @@ current.id = message.id current.string = message.string current.locations.extend(message.locations) - current.comments.extend(message.comments) + current.auto_comments.extend(message.auto_comments) + current.user_comments.extend(message.user_comments) current.flags |= message.flags message = current else: @@ -381,7 +385,8 @@ assert isinstance(message.string, (list, tuple)) self._messages[key] = message - def add(self, id, string=None, locations=(), flags=(), comments=()): + def add(self, id, string=None, locations=(), flags=(), auto_comments=(), + user_comments=()): """Add or update the message with the specified ID. >>> catalog = Catalog() @@ -400,7 +405,8 @@ :param flags: a set or sequence of flags :param comments: a list of translator comments """ - self[id] = Message(id, string, list(locations), flags, comments) + self[id] = Message(id, string, list(locations), flags, auto_comments, + user_comments) def _key_for(self, id): """The key for a message is just the singular ID even for pluralizable