Mercurial > babel > old > mirror
changeset 153:90866b11734f stable
Merged [141:143] and [145:153] via svnmerge from [source:/trunk].
author | cmlenz |
---|---|
date | Wed, 20 Jun 2007 20:59:10 +0000 |
parents | 8999fdba2f93 |
children | 8418aa876f76 |
files | 0.8.x/babel/core.py 0.8.x/babel/messages/catalog.py 0.8.x/babel/messages/extract.py 0.8.x/babel/messages/pofile.py |
diffstat | 4 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/0.8.x/babel/core.py +++ b/0.8.x/babel/core.py @@ -539,6 +539,10 @@ for name in filter(None, varnames): locale = os.getenv(name) if locale: + if name == 'LANGUAGE' and ':' in locale: + # the LANGUAGE variable may contain a colon-separated list of + # language codes; we just pick the language on the list + locale = locale.split(':')[0] return '_'.join(filter(None, parse_locale(locale))) def negotiate_locale(preferred, available, sep='_'):
--- a/0.8.x/babel/messages/catalog.py +++ b/0.8.x/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.
--- a/0.8.x/babel/messages/extract.py +++ b/0.8.x/babel/messages/extract.py @@ -260,7 +260,7 @@ elif tok == COMMENT: # Strip the comment token from the line value = value[1:].strip() - if in_translator_comments is True and \ + if in_translator_comments and \ translator_comments[-1][0] == lineno - 1: # We're already inside a translator comment, continue appending # XXX: Should we check if the programmer keeps adding the @@ -271,8 +271,7 @@ # starts with one of the comment tags for comment_tag in comment_tags: if value.startswith(comment_tag): - if in_translator_comments is not True: - in_translator_comments = True + in_translator_comments = True comment = value[len(comment_tag):].strip() translator_comments.append((lineno, comment)) break
--- a/0.8.x/babel/messages/pofile.py +++ b/0.8.x/babel/messages/pofile.py @@ -60,12 +60,12 @@ ... print (message.id, message.string) ... print ' ', (message.locations, message.flags) ... print ' ', (message.user_comments, message.auto_comments) - ('foo %(name)s', '') - ([('main.py', 1)], set(['fuzzy', 'python-format'])) + (u'foo %(name)s', '') + ([(u'main.py', 1)], set([u'fuzzy', u'python-format'])) ([], []) - (('bar', 'baz'), ('', '')) - ([('main.py', 3)], set([])) - (['A user comment'], ['An auto comment']) + ((u'bar', u'baz'), ('', '')) + ([(u'main.py', 3)], set([])) + ([u'A user comment'], [u'An auto comment']) :param fileobj: the file-like object to read the PO file from :return: an iterator over ``(message, translation, location)`` tuples @@ -97,7 +97,7 @@ del flags[:]; del auto_comments[:]; del user_comments[:] for line in fileobj.readlines(): - line = line.strip() + line = line.strip().decode(catalog.charset) if line.startswith('#'): in_msgid = in_msgstr = False if messages: