def normalize(code):
    """
    Normalize language codes to ISO 639-2. If all conversions fails, return the
    `code` as it was given.

    Args:
        code (str): Language / country code.

    Returns:
        str: ISO 639-2 country code.
    """
    if len(code) == 3:
        return code

    normalized = translate(code)

    if normalized:
        return normalized

    country = countries.get(code, None)

    if country:
        return country.alpha3.lower()

    return code
def normalize ( code ) : if len ( code ) == 3 : return code normalized = translate ( code ) if normalized : return normalized country = countries . get ( code , None ) if country : return country . alpha3 . lower ( ) return code
Normalize language codes to ISO 639-2. If all conversions fails, return the
    `code` as it was given.

    Args:
        code (str): Language / country code.

    Returns:
        str: ISO 639-2 country code.