def __call__(self, environ, start_response):
        req = Request(environ)
        preferred_languages = list(req.accept_language)
        if self.default_language not in preferred_languages:
            preferred_languages.append(self.default_language)
        translation = gettext.translation(
            'messages', self.locale_path, fallback=True,
            languages=preferred_languages, codeset='utf-8')
        translation.install(unicode=True, names=['gettext', 'ngettext'])
        environ['i18n_utils.active_translation'] = translation
        environ['i18n_utils.preferred_languages'] = preferred_languages

        return self.app(environ, start_response)
Called by WSGI when a request comes in.
dataset/ETHPy150Open GoogleCloudPlatform/python-docs-samples/appengine/i18n/i18n_utils.py/I18nMiddleware.__call__