def get_localized_next_url(self, locale=None):
        if locale is None:
            locale = self.locale
        next_url = self.get_redirect_target()
        if next_url is None:
            return
        scheme, netloc, path, query = urlsplit(next_url)[:4]
        path = path.decode('utf-8')

        # aha. we're redirecting somewhere out of our control
        if netloc != self.host or not path.startswith(self.script_root):
            return next_url

        path = path[len(self.script_root):]
        try:
            endpoint, values = self.url_adapter.match(path)
        except NotFound, e:
            return next_url
        except RequestRedirect:
            pass
        if 'lang_code' not in values:
            return next_url

        values['lang_code'] = str(locale)
        return self.url_adapter.build(endpoint, values) + \
               (query and '?' + query or '')
Like `next_url` but tries to go to the localized section.
dataset/ETHPy150Open mitsuhiko/solace/solace/application.py/Request.get_localized_next_url