Mercurial > babel > old > mirror
diff babel/messages/catalog.py @ 82:f421e5576d26
Added support for translator comments at the API and frontends levels.(See #12, item 1). Updated docs and tests accordingly.
author | palgarvio |
---|---|
date | Sun, 10 Jun 2007 14:21:01 +0000 |
parents | 8e2e9d549693 |
children | 8a703ecdba91 |
line wrap: on
line diff
--- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -35,7 +35,7 @@ class Message(object): """Representation of a single message in a catalog.""" - def __init__(self, id, string='', locations=(), flags=()): + def __init__(self, id, string='', locations=(), flags=(), comments=[]): """Create the message object. :param id: the message ID, or a ``(singular, plural)`` tuple for @@ -44,6 +44,7 @@ ``(singular, plural)`` tuple for pluralizable messages :param locations: a sequence of ``(filenname, lineno)`` tuples :param flags: a set or sequence of flags + :param comments: a list of comments for the msgid """ self.id = id if not string and self.pluralizable: @@ -55,6 +56,7 @@ self.flags.add('python-format') else: self.flags.discard('python-format') + self.comments = comments def __repr__(self): return '<%s %r>' % (type(self).__name__, self.id) @@ -328,7 +330,7 @@ assert isinstance(message.string, (list, tuple)) self._messages[key] = message - def add(self, id, string=None, locations=(), flags=()): + def add(self, id, string=None, locations=(), flags=(), comments=[]): """Add or update the message with the specified ID. >>> catalog = Catalog() @@ -345,8 +347,9 @@ ``(singular, plural)`` tuple for pluralizable messages :param locations: a sequence of ``(filenname, lineno)`` tuples :param flags: a set or sequence of flags + :param comments: a list of comments for the msgid """ - self[id] = Message(id, string, list(locations), flags) + self[id] = Message(id, string, list(locations), flags, comments) def _key_for(self, id): """The key for a message is just the singular ID even for pluralizable