Mercurial > hg
comparison mercurial/i18n.py @ 7948:de377b1a9a84
move encoding bits from util to encoding
In addition to cleaning up util, this gets rid of some circular dependencies.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 03 Apr 2009 14:51:48 -0500 |
parents | 5b5036ef847a |
children | 46293a0c7e9f |
comparison
equal
deleted
inserted
replaced
7947:a454eeb1b827 | 7948:de377b1a9a84 |
---|---|
5 | 5 |
6 This software may be used and distributed according to the terms | 6 This software may be used and distributed according to the terms |
7 of the GNU General Public License, incorporated herein by reference. | 7 of the GNU General Public License, incorporated herein by reference. |
8 """ | 8 """ |
9 | 9 |
10 import gettext, sys, os | 10 import gettext, sys, os, encoding |
11 | 11 |
12 # modelled after templater.templatepath: | 12 # modelled after templater.templatepath: |
13 if hasattr(sys, 'frozen'): | 13 if hasattr(sys, 'frozen'): |
14 module = sys.executable | 14 module = sys.executable |
15 else: | 15 else: |
35 # If message is None, t.ugettext will return u'None' as the | 35 # If message is None, t.ugettext will return u'None' as the |
36 # translation whereas our callers expect us to return None. | 36 # translation whereas our callers expect us to return None. |
37 if message is None: | 37 if message is None: |
38 return message | 38 return message |
39 | 39 |
40 # We cannot just run the text through util.tolocal since that | 40 # We cannot just run the text through encoding.tolocal since that |
41 # leads to infinite recursion when util._encoding is invalid. | 41 # leads to infinite recursion when encoding._encoding is invalid. |
42 try: | 42 try: |
43 u = t.ugettext(message) | 43 u = t.ugettext(message) |
44 return u.encode(util._encoding, "replace") | 44 return u.encode(encoding.encoding, "replace") |
45 except LookupError: | 45 except LookupError: |
46 return message | 46 return message |
47 | 47 |
48 _ = gettext | 48 _ = gettext |
49 | 49 |
50 # Moved after _ because of circular import. | |
51 import util |