def normalize_lang(lang):
    """Normalize input languages string

    >>> from pyams_utils.i18n import normalize_lang
    >>> lang = 'fr,en_US ; q=0.9, en-GB ; q=0.8, en ; q=0.7'
    >>> normalize_lang(lang)
    'fr,en-us;q=0.9,en-gb;q=0.8,en;q=0.7'
    """
    return lang.strip() \
               .lower() \
               .replace('_', '-') \
               .replace(' ', '')