Пример #1
0
def init_single_instance():
    if not config_true(get_config_value('allow_multiple_instances', 'False')):
        single_instance = SingleInstance()

        if single_instance.aleradyrunning():
            write_named_pipe('cddagl_instance', b'dupe')
            sys.exit(0)

        return single_instance

    return None
Пример #2
0
def init_single_instance():
    if not config_true(get_config_value('allow_multiple_instances', 'False')):
        single_instance = SingleInstance()

        if single_instance.aleradyrunning():
            write_named_pipe('cddagl_instance', b'dupe')
            sys.exit(0)

        return single_instance

    return None
Пример #3
0
def init_gettext():
    locale_dir = os.path.join(basedir, 'cddagl', 'locale')
    preferred_locales = []

    selected_locale = get_config_value('locale', None)
    if selected_locale == 'None':
        selected_locale = None
    if selected_locale is not None:
        preferred_locales.append(selected_locale)

    system_locale = get_ui_locale()
    if system_locale is not None:
        preferred_locales.append(system_locale)

    if os.path.isdir(locale_dir):
        entries = scandir(locale_dir)
        for entry in entries:
            if entry.is_dir():
                available_locales.append(entry.name)

    available_locales.sort(key=lambda x: 0 if x == 'en' else 1)

    app_locale = Locale.negotiate(preferred_locales, available_locales)
    if app_locale is None:
        app_locale = 'en'
    else:
        app_locale = str(app_locale)

    try:
        t = gettext.translation('cddagl',
                                localedir=locale_dir,
                                languages=[app_locale])
        global _
        _ = t.gettext
    except FileNotFoundError as e:
        pass

    return app_locale
Пример #4
0
def init_gettext():
    locale_dir = os.path.join(basedir, 'cddagl', 'locale')
    preferred_locales = []

    selected_locale = get_config_value('locale', None)
    if selected_locale == 'None':
        selected_locale = None
    if selected_locale is not None:
        preferred_locales.append(selected_locale)

    system_locale = get_ui_locale()
    if system_locale is not None:
        preferred_locales.append(system_locale)

    if os.path.isdir(locale_dir):
        entries = scandir(locale_dir)
        for entry in entries:
            if entry.is_dir():
                available_locales.append(entry.name)

    available_locales.sort(key=lambda x: 0 if x == 'en' else 1)

    app_locale = Locale.negotiate(preferred_locales, available_locales)
    if app_locale is None:
        app_locale = 'en'
    else:
        app_locale = str(app_locale)

    try:
        t = gettext.translation('cddagl', localedir=locale_dir,
            languages=[app_locale])
        global _
        _ = t.gettext
    except FileNotFoundError as e:
        pass

    return app_locale