import re


def check_language_code(code_def):
    """
    Takes a language code string and checks if it is a correct one, and retrieve variant
    details if any.

    Returns:
    None in case of failure; (language_code, [language_variant]) in case of success.
    For instance:
    * check_language_code('xxx') returns None;
    * check_language_code('it') returns ('it', None);
    * check_language_code('en-us') returns ('en','us');
    """
    match = re.match('^(?P<language>[a-z]{2})(\-(?P<variant>[a-z]{2}))?$', code_def)
    if match:
        return (match.group('language'), match.group('variant'))
    else:
        return None