comparison mercurial/i18n.py @ 9320:884964f99e07

i18n: move unrelated line out of try-except block
author Martin Geisler <mg@lazybytes.net>
date Thu, 06 Aug 2009 00:34:28 +0200
parents 8982eb292cb5
children f96ee862aba0
comparison
equal deleted inserted replaced
9319:8982eb292cb5 9320:884964f99e07
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 u = t.ugettext(message)
39 try: 40 try:
40 # encoding.tolocal cannot be used since it will first try to 41 # encoding.tolocal cannot be used since it will first try to
41 # decode the Unicode string. Calling u.decode(enc) really 42 # decode the Unicode string. Calling u.decode(enc) really
42 # means u.encode(sys.getdefaultencoding()).decode(enc). Since 43 # means u.encode(sys.getdefaultencoding()).decode(enc). Since
43 # the Python encoding defaults to 'ascii', this fails if the 44 # the Python encoding defaults to 'ascii', this fails if the
44 # translated string use non-ASCII characters. 45 # translated string use non-ASCII characters.
45 u = t.ugettext(message)
46 return u.encode(encoding.encoding, "replace") 46 return u.encode(encoding.encoding, "replace")
47 except LookupError: 47 except LookupError:
48 # An unknown encoding results in a LookupError.
48 return message 49 return message
49 50
50 _ = gettext 51 _ = gettext
51 52