<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def init (domain, directory, loc=None):
 """Initialize this gettext i18n module. Searches for supported languages and installs the gettext translator class."""

    global default_language, default_encoding, default_domain, default_directory
    default_directory = directory
    default_domain = domain
    if os.path.isdir(directory):
        # get supported languages
        for lang in os.listdir(directory):
            path = os.path.join(directory, lang, 'LC_MESSAGES')
            mo_file = os.path.join(path, '%s.mo' % domain)
            if os.path.exists(mo_file):
                supported_languages.add(lang)
    if loc is None:
        loc, encoding = get_locale()
    else:
        encoding = get_locale()[1]
    if loc in supported_languages:
        default_language = loc
    else:
        default_language = "en"
    # Even if the default language is not supported, the encoding should
    # be installed. Otherwise the Python installation is borked.
    default_encoding = encoding
    install_language(default_language)