def _parse_localename(localename):
code = normalize(localename)<EOL>if '<STR_LIT:@>' in code:<EOL><INDENT>code, modifier = code.split('<STR_LIT:@>', <NUM_LIT:1>)<EOL>if modifier == '<STR_LIT>' and '<STR_LIT:.>' not in code:<EOL><INDENT>return code, '<STR_LIT>'<EOL><DEDENT><DEDENT>if '<STR_LIT:.>' in code:<EOL><INDENT>return tuple(code.split('<STR_LIT:.>')[:<NUM_LIT:2>])<EOL><DEDENT>elif code == '<STR_LIT:C>':<EOL><INDENT>return None, None<EOL><DEDENT>raise ValueError('<STR_LIT>' % localename)<EOL>
Parses the locale code for localename and returns the
        result as tuple (language code, encoding).

        The localename is normalized and passed through the locale
        alias engine. A ValueError is raised in case the locale name
        cannot be parsed.

        The language code corresponds to RFC 1766.  code and encoding
        can be None in case the values cannot be determined or are
        unknown to this implementation.