Пример #1
0
def get_current_formats():
    formats = global_state.get_config('formats')
    if not formats:
        formats = global_state.get_config('locale')
        global_state.set_config('formats', formats)
    name = GnomeDesktop.get_country_from_locale(formats)
    if not name:
        # solely to prevent crashes, e.g. for Esperanto
        # TODO add to translatation
        name = 'Undefined'
    return (name, formats)
Пример #2
0
def get_formats():
    formats = []
    # separate name set to prevent duplicates in list
    # see gnome-desktop issue https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3610
    names = set()
    translation_locale = global_state.get_config('locale')

    for locale in locales:
        name = GnomeDesktop.get_country_from_locale(locale, translation_locale)
        if name and not name in names:
            names.add(name)
            formats.append((name, locale))

    # return sorted (considers umlauts and such)
    return sorted(formats, key=lambda t: Locale.strxfrm(t[0]))