pamhyr.py 1.13 KiB
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys, os
import locale

from PyQt5.QtCore import QTranslator
from PyQt5.QtWidgets import QApplication

from config import Config
from tools import (
    reset_timers, display_timers, timer
)

from View.MainWindow import ApplicationWindow
from Model.Study import Study

def main():
    reset_timers()
    conf = Config.load()
    app = QApplication(sys.argv)

    translator = QTranslator()

    lang_file = ""
    if conf.lang == "":
        # System language
        sys_lang = locale.getdefaultlocale()
        if "fr" in sys_lang[0]:
            lang_file = os.path.dirname(__file__) + "/lang/fr.qm"
    elif conf.lang == "fr":
        # French
        lang_file = os.path.dirname(__file__) + "/lang/fr.qm"
    else:
        lang_file = ""
        # English default language

    if lang_file != "":
        ok = translator.load(lang_file)
        if not ok:
            print("failed")

    app.installTranslator(translator)

    application = ApplicationWindow(conf=conf)
    application.show()

    ret = app.exec_()
    display_timers()
    sys.exit(ret)

if __name__ == "__main__":
    main()