-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
63 lines (51 loc) · 1.56 KB
/
Copy path__init__.py
File metadata and controls
63 lines (51 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Standalone kernel enabling sophisticated console / UI applications."""
from .channel import *
from .context import *
from .exceptions import *
from .functions import *
from .jobs import *
from .kernel import *
from .lifecycles import *
from .module import *
from .service import *
from .settings import *
_gettext = lambda e: e
_gettext_language = None
def _(message):
return _gettext(message)
def set_language(domain, localedir, language):
import gettext
import sys
localedirs = list()
try: # pyinstaller internal location
# pylint: disable=no-member
_resource_path = os.path.join(sys._MEIPASS, localedir)
localedirs.append(_resource_path)
except Exception:
pass
try: # Mac py2app resource
_resource_path = os.path.join(os.environ["RESOURCEPATH"], localedir)
localedirs.append(_resource_path)
except Exception:
pass
localedirs.append(localedir)
# Default Locale, prepended. Check this first.
basepath = os.path.abspath(os.path.dirname(sys.argv[0]))
working_dir = os.path.join(basepath, localedir)
localedirs.append(working_dir)
localedirs.append(None)
for ld in localedirs:
try:
el = gettext.translation(
domain,
localedir=ld,
languages=[language],
fallback=ld is None,
)
except FileNotFoundError:
continue
el.install()
global _gettext, _gettext_language
_gettext = el.gettext
_gettext_language = language
break