Ejemplo n.º 1
0
def process_locales(series):
    """Convert locale codes to pretty names, skip any unknown locales."""
    languages = {key.lower(): value['native'] for key, value in ALL_LANGUAGES.items()}

    for row in series:
        if 'data' in row:
            new = {}
            for key, count in row['data'].items():
                if key and key.lower() in languages:
                    k = '%s (%s)' % (languages[key.lower()], key)
                    new[k] = count
            row['data'] = new
        yield row
Ejemplo n.º 2
0
def process_locales(series):
    """Convert locale codes to pretty names, skip any unknown locales."""
    languages = {
        key.lower(): value['native']
        for key, value in ALL_LANGUAGES.items()}

    for row in series:
        if 'data' in row:
            new = {}
            for key, count in row['data'].items():
                if key in languages:
                    k = u'%s (%s)' % (languages[key], key)
                    new[k] = count
            row['data'] = new
        yield row