Mercurial > babel > old > mirror
diff babel/messages/catalog.py @ 151:12e5f21dfcda
Respect charset specified in PO headers in `read_po()`. Fixes #17.
author | cmlenz |
---|---|
date | Wed, 20 Jun 2007 20:31:24 +0000 |
parents | 9d58665d134c |
children | eafaa302dde1 |
line wrap: on
line diff
--- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -13,6 +13,7 @@ """Data structures for message catalogs.""" +from cgi import parse_header from datetime import datetime from email import message_from_string import re @@ -37,7 +38,7 @@ class Message(object): """Representation of a single message in a catalog.""" - def __init__(self, id, string='', locations=(), flags=(), auto_comments=(), + def __init__(self, id, string=u'', locations=(), flags=(), auto_comments=(), user_comments=()): """Create the message object. @@ -263,6 +264,10 @@ int(tzoffset[2:])) dt = datetime.fromtimestamp(ts) self.creation_date = dt.replace(tzinfo=tzoffset) + elif name == 'content-type': + mimetype, params = parse_header(value) + if 'charset' in params: + self.charset = params['charset'].lower() mime_headers = property(_get_mime_headers, _set_mime_headers, doc="""\ The MIME headers of the catalog, used for the special ``msgid ""`` entry.