equal
deleted
inserted
replaced
11 import locale |
11 import locale |
12 import os |
12 import os |
13 import sys |
13 import sys |
14 |
14 |
15 from .pycompat import getattr |
15 from .pycompat import getattr |
|
16 from .utils import resourceutil |
16 from . import ( |
17 from . import ( |
17 encoding, |
18 encoding, |
18 pycompat, |
19 pycompat, |
19 ) |
20 ) |
20 |
21 |
43 _languages = [locale.windows_locale[langid]] |
44 _languages = [locale.windows_locale[langid]] |
44 except (ImportError, AttributeError, KeyError): |
45 except (ImportError, AttributeError, KeyError): |
45 # ctypes not found or unknown langid |
46 # ctypes not found or unknown langid |
46 pass |
47 pass |
47 |
48 |
48 _ugettext = None |
|
49 |
49 |
50 |
50 datapath = pycompat.fsdecode(resourceutil.datapath) |
51 def setdatapath(datapath): |
51 localedir = os.path.join(datapath, 'locale') |
52 datapath = pycompat.fsdecode(datapath) |
52 t = gettextmod.translation('hg', localedir, _languages, fallback=True) |
53 localedir = os.path.join(datapath, 'locale') |
53 try: |
54 t = gettextmod.translation('hg', localedir, _languages, fallback=True) |
54 _ugettext = t.ugettext |
55 global _ugettext |
55 except AttributeError: |
56 try: |
56 _ugettext = t.gettext |
57 _ugettext = t.ugettext |
|
58 except AttributeError: |
|
59 _ugettext = t.gettext |
|
60 |
57 |
61 |
58 |
62 _msgcache = {} # encoding: {message: translation} |
59 _msgcache = {} # encoding: {message: translation} |
63 |
60 |
64 |
61 |