Beispiel #1
0
def preferred():
    """Return a list of language codes from the operating system preferences.
    
    Language- and country codes will always be separated with an underscore '_'.
    
    """
    try:
        langs = QLocale().uiLanguages()
    except AttributeError:
        # QLocale.uiLanguages is not in Qt 4.7 (only Qt4.8+)
        langs = []
    else:
        # in some systems, language/country codes have '-' and not '_'
        langs = [l.replace('-', '_') for l in langs]
    if not langs:
        try: 
            langs.append(locale.getdefaultlocale()[0])
        except ValueError:
            pass
    return langs
Beispiel #2
0
def preferred():
    """Return a list of language codes from the operating system preferences.
    
    Language- and country codes will always be separated with an underscore '_'.
    
    """
    try:
        langs = QLocale().uiLanguages()
    except AttributeError:
        # QLocale.uiLanguages is not in Qt 4.7 (only Qt4.8+)
        langs = []
    else:
        # in some systems, language/country codes have '-' and not '_'
        langs = [l.replace('-', '_') for l in langs]
    if not langs:
        try:
            langs.append(locale.getdefaultlocale()[0])
        except ValueError:
            pass
    return langs