Skip to content

xpuz.__main__ ¤

Entry point of xpuz.

_get_os_language ¤

_get_os_language() -> str

Infer language code from operating system data.

Returns:

Type Description
str

The locale.

Source code in src/xpuz/__main__.py
19
20
21
22
23
24
25
26
27
28
29
30
def _get_os_language() -> str:
    """Infer language code from operating system data.

    Returns:
        The locale.
    """
    if os_name == "posix":
        return environ["LANG"].split("-")[0]
    else:
        return windows_locale[
            windll.kernel32.GetUserDefaultUILanguage()
        ].split("-")[0]

main ¤

main() -> None

Main function to initialise the xpuz GUI.

Source code in src/xpuz/__main__.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def main() -> None:
    """Main function to initialise the `xpuz` GUI."""
    cfg: ConfigParser = ConfigParser()
    _read_cfg(cfg)

    locale: Locale = Locale.parse(cfg.get("m", "language"))
    # First-time initialisation, try detecting the OS locale
    if int(cfg.get("misc", "launches")) == 0:
        try:
            locale: Locale = Locale.parse(_get_os_language())
            _update_cfg(cfg, "m", "language", locale.language)
        except Exception:
            pass

    GUIHelper._install_translations(locale)
    app: Base = Base(locale=locale, lang_info=_get_language_options(), cfg=cfg)
    app.mainloop()