def get_valid_language(record, field):
    """
    Takes languages codes and returns the first in a valid form.
    """
    languages = record.field(field, alt='')
    if '$$' in languages:
        languages = languages.split('$$')
    elif ';' in languages:
        languages = languages.split(' ; ')
    else:
        languages = languages.split('$')
    return languages[0]
