示例#1
0
    def test_with_weirder_prefix(self):
        activate('en-us')
        self.assertEqual(url_for_language('/en-us/about/', 'es'), '/es/about/')

        activate('es')
        self.assertEqual(url_for_language('/es/about/', 'es-mx'),
                         '/es-mx/about/')
示例#2
0
    def test_translated_unnamed_urls(self):
        activate('en')
        url = reverse('tests.urls.unnamed_view', kwargs={'k1': 'foo'})

        self.assertEqual(url, '/en/the-unnamed-url/foo/')
        self.assertEqual(url_for_language(url, 'es'),
                         '/es/el-url-sin-nombre/foo/')
示例#3
0
    def test_translated_urls(self):
        activate('en')
        url = reverse('translated_url', kwargs={'k1': 'foo'})

        self.assertEqual(url, '/en/the-url/foo/')
        self.assertEqual(url_for_language(url, 'es'), '/es/el-url/foo/')
示例#4
0
 def test_possible_false_positive(self):
     activate('en')
     self.assertEqual(url_for_language('/enable/', 'en'), '/en/enable/')
     self.assertEqual(url_for_language('/enable/', 'es'), '/es/enable/')
示例#5
0
 def test_with_host(self):
     activate('en')
     url = 'http://example.com/en/about/'
     self.assertEqual(url_for_language(url, 'es'),
                      'http://example.com/es/about/')
示例#6
0
 def test_with_language(self):
     activate('en')
     self.assertEqual(url_for_language('/en/about/', 'en'), '/en/about/')
     self.assertEqual(url_for_language('/en/about/', 'es'), '/es/about/')
示例#7
0
 def get_redirect_url(self, **kwargs):
     new_language = self.request.POST.get('language', None)
     url = self.get_next_url()
     return url_for_language(url, new_language)
示例#8
0
 def get_redirect_url(self, **kwargs):
     new_language = self.request.POST.get('language', None)
     url = self.get_next_url()
     return url_for_language(url, new_language)