make language changeable
This commit is contained in:
20
main.py
20
main.py
@@ -16,6 +16,8 @@ from ravenui import RavenUI
|
||||
|
||||
import gettext
|
||||
|
||||
from settingsstore import SettingsStore
|
||||
|
||||
gettext.install('ravenlog', 'locale')
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
@@ -43,22 +45,6 @@ if __name__ == "__main__":
|
||||
myappid = 'opentext.ravenlog' # arbitrary string
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
|
||||
|
||||
locale = os.environ['LANG'] if os.environ['LANG'] else "en"
|
||||
|
||||
src_dir = Path(__file__).resolve().parent
|
||||
try:
|
||||
translation = gettext.translation('messages', localedir=src_dir / 'locales', languages=[locale])
|
||||
if translation:
|
||||
translation.install()
|
||||
_ = translation.gettext
|
||||
ngettext = translation.ngettext
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
if not _:
|
||||
_ = gettext.gettext
|
||||
ngettext = gettext.ngettext
|
||||
print('No translation found')
|
||||
|
||||
# workaround to make signals work in QT apps.
|
||||
# They do not work out of the box, because the main thread
|
||||
# is running in C++ code once app.exec() is executed
|
||||
@@ -74,8 +60,6 @@ if __name__ == "__main__":
|
||||
PluginRegistry.load_plugin("LogFilePlugin")
|
||||
PluginRegistry.load_plugin("NotesPlugin")
|
||||
|
||||
PluginRegistry.execute("set_translator", lambda string: translator.tr(string))
|
||||
|
||||
window = PluginRegistry.execute_single("create_main_window")
|
||||
RavenUI.window = window
|
||||
window.show()
|
||||
|
||||
Reference in New Issue
Block a user