Mercurial > babel > mirror
diff babel/messages/pofile.py @ 585:5c9dba5dd311 trunk
handle irregular multi-line msgstr (no "" as first line) gracefully (#171)
author | fschwarz |
---|---|
date | Sat, 04 Aug 2012 23:10:41 +0000 |
parents | 3fd7fb953633 |
children | 46410022772a |
line wrap: on
line diff
--- a/babel/messages/pofile.py +++ b/babel/messages/pofile.py @@ -75,10 +75,11 @@ :return: the denormalized string :rtype: `unicode` or `str` """ - if string.startswith('""'): - lines = [] - for line in string.splitlines()[1:]: - lines.append(unescape(line)) + if '\n' in string: + escaped_lines = string.splitlines() + if string.startswith('""'): + escaped_lines = escaped_lines[1:] + lines = map(unescape, escaped_lines) return ''.join(lines) else: return unescape(string) @@ -110,10 +111,10 @@ ... print (message.id, message.string) ... print ' ', (message.locations, message.flags) ... print ' ', (message.user_comments, message.auto_comments) - (u'foo %(name)s', '') + (u'foo %(name)s', u'') ([(u'main.py', 1)], set([u'fuzzy', u'python-format'])) ([], []) - ((u'bar', u'baz'), ('', '')) + ((u'bar', u'baz'), (u'', u'')) ([(u'main.py', 3)], set([])) ([u'A user comment'], [u'An auto comment'])