20d332aa40c2e793bc9dbe5eea7b6f63dcbfbcdb
1 from logging
import info
2 from os
.path
import join
, exists
, dirname
3 from gettext
import translation
4 from pathlib
import Path
5 from ya2
.patterns
.gameobject
import GameObject
9 def is_runtime(): return not exists('main.py')
13 par_path
= str(Path(__file__
).parent
.absolute())
14 is_appimage
= par_path
.startswith('/tmp/.mount_Pmachines')
15 return is_appimage
and par_path
.endswith('/usr/bin')
21 if sys
.platform
== 'darwin':
22 return dirname(__file__
) + '/../Resources/'
23 # return dirname(__file__)
24 par_path
= str(Path(__file__
).parent
.absolute())
26 return str(Path(par_path
).absolute())
27 is_snap
= par_path
.startswith('/snap/')
28 is_snap
= is_snap
and par_path
.endswith('/x1')
30 return str(Path(par_path
).absolute())
32 curr_path
= dirname(__file__
)
33 info('current path: %s' % curr_path
)
34 return curr_path
+ '/'
37 class LangMgr(GameObject
):
39 def __init__(self
, lang
, domain
, dpath
):
40 GameObject
.__init
__(self
)
43 self
.dpath
= join(curr_path(), dpath
)
44 info('language: %s, %s' % (self
.domain
, self
.dpath
))
49 return [lang
[1] for lang
in self
.eng
.cfg
.lang_cfg
.languages
]
51 def set_lang(self
, lang
):
53 args
= lang
, self
.domain
, self
.dpath
54 info('setting language %s, %s, %s' % args
)
55 tra
= translation(self
.domain
, self
.dpath
, [lang
], fallback
=True)