Esempio n. 1
0
    def localised_urls(self):
        localised = []
        requested_language = translation.get_language()
        url_parts = urlparse(self.request.build_absolute_uri())
        base_url = f'{url_parts.scheme}://{url_parts.netloc}/'

        for code, language in self.available_languages:
            if code == requested_language:
                continue
            else:
                if code == 'en-gb':
                    localised_page = base_url + get_untranslated_url(
                        self.request.path)[1:]
                else:
                    localised_page = base_url + code + get_untranslated_url(
                        self.request.path)
                localised.append([localised_page, code])

        return localised
Esempio n. 2
0
def untranslated_url(request):
    untranslated_url = get_untranslated_url(request.path)
    return {'untranslated_url': untranslated_url}
Esempio n. 3
0
def test_get_untranslated_url(prefixed_url, exp_url):
    url = helpers.get_untranslated_url(prefixed_url)
    assert url == exp_url