Mercurial > hg
comparison mercurial/i18n.py @ 21746:2d47d81c79fb
i18n: explicitly decode paragraphs
This was triggering an exception when the default encoding was disabled.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 12 Jun 2014 14:40:45 -0500 |
parents | b64538363dbe |
children | 4953cd193e84 |
comparison
equal
deleted
inserted
replaced
21745:4c62478be2ea | 21746:2d47d81c79fb |
---|---|
34 # If message is None, t.ugettext will return u'None' as the | 34 # If message is None, t.ugettext will return u'None' as the |
35 # translation whereas our callers expect us to return None. | 35 # translation whereas our callers expect us to return None. |
36 if message is None: | 36 if message is None: |
37 return message | 37 return message |
38 | 38 |
39 paragraphs = message.split('\n\n') | 39 if type(message) is unicode: |
40 # goofy unicode docstrings in test | |
41 paragraphs = message.split(u'\n\n') | |
42 else: | |
43 paragraphs = [p.decode("ascii") for p in message.split('\n\n')] | |
40 # Be careful not to translate the empty string -- it holds the | 44 # Be careful not to translate the empty string -- it holds the |
41 # meta data of the .po file. | 45 # meta data of the .po file. |
42 u = u'\n\n'.join([p and t.ugettext(p) or '' for p in paragraphs]) | 46 u = u'\n\n'.join([p and t.ugettext(p) or '' for p in paragraphs]) |
43 try: | 47 try: |
44 # encoding.tolocal cannot be used since it will first try to | 48 # encoding.tolocal cannot be used since it will first try to |