def register_type(env_type, alias=None):
    """Registers environment type.

    :param str|unicode|Environment env_type: Environment type or its alias
        (for already registered types).

    :param str|unicode alias: Alias to register type under. If not set type name is used.

    :rtype: Environment

    """
    if isinstance(env_type, string_types):
        env_type = TYPES[env_type]

    if alias is None:
        alias = env_type.name

    TYPES[alias] = env_type

    for alias in env_type.aliases:
        TYPES[alias] = env_type

    return env_type