equal
deleted
inserted
replaced
10 import gettext as gettextmod |
10 import gettext as gettextmod |
11 import locale |
11 import locale |
12 import os |
12 import os |
13 import sys |
13 import sys |
14 |
14 |
15 from . import encoding |
15 from . import ( |
|
16 encoding, |
|
17 pycompat, |
|
18 ) |
16 |
19 |
17 # modelled after templater.templatepath: |
20 # modelled after templater.templatepath: |
18 if getattr(sys, 'frozen', None) is not None: |
21 if getattr(sys, 'frozen', None) is not None: |
19 module = sys.executable |
22 module = sys.executable |
20 else: |
23 else: |
83 # encoding.tolocal cannot be used since it will first try to |
86 # encoding.tolocal cannot be used since it will first try to |
84 # decode the Unicode string. Calling u.decode(enc) really |
87 # decode the Unicode string. Calling u.decode(enc) really |
85 # means u.encode(sys.getdefaultencoding()).decode(enc). Since |
88 # means u.encode(sys.getdefaultencoding()).decode(enc). Since |
86 # the Python encoding defaults to 'ascii', this fails if the |
89 # the Python encoding defaults to 'ascii', this fails if the |
87 # translated string use non-ASCII characters. |
90 # translated string use non-ASCII characters. |
88 _msgcache[message] = u.encode(encoding.encoding, "replace") |
91 encodingstr = pycompat.sysstr(encoding.encoding) |
|
92 _msgcache[message] = u.encode(encodingstr, "replace") |
89 except LookupError: |
93 except LookupError: |
90 # An unknown encoding results in a LookupError. |
94 # An unknown encoding results in a LookupError. |
91 _msgcache[message] = message |
95 _msgcache[message] = message |
92 return _msgcache[message] |
96 return _msgcache[message] |
93 |
97 |