mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Fixed #33078 -- Added support for language regions in i18n_patterns().
This commit is contained in:
		
				
					committed by
					
						 Mariusz Felisiak
						Mariusz Felisiak
					
				
			
			
				
	
			
			
			
						parent
						
							4f7bbc6138
						
					
				
				
					commit
					d3f4c2b95d
				
			| @@ -43,7 +43,7 @@ language_code_re = _lazy_re_compile( | ||||
|     re.IGNORECASE | ||||
| ) | ||||
|  | ||||
| language_code_prefix_re = _lazy_re_compile(r'^/(\w+([@-]\w+)?)(/|$)') | ||||
| language_code_prefix_re = _lazy_re_compile(r'^/(\w+([@-]\w+){0,2})(/|$)') | ||||
|  | ||||
|  | ||||
| @receiver(setting_changed) | ||||
|   | ||||
| @@ -183,7 +183,8 @@ Generic Views | ||||
| Internationalization | ||||
| ~~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
| * ... | ||||
| * The :func:`~django.conf.urls.i18n.i18n_patterns` function now supports | ||||
|   languages with both scripts and regions. | ||||
|  | ||||
| Logging | ||||
| ~~~~~~~ | ||||
|   | ||||
| @@ -1593,11 +1593,15 @@ class MiscTests(SimpleTestCase): | ||||
|     @override_settings( | ||||
|         LANGUAGES=[ | ||||
|             ('en', 'English'), | ||||
|             ('en-latn-us', 'Latin English'), | ||||
|             ('en-Latn-US', 'BCP 47 case format'), | ||||
|             ('de', 'German'), | ||||
|             ('de-1996', 'German, orthography of 1996'), | ||||
|             ('de-at', 'Austrian German'), | ||||
|             ('de-ch-1901', 'German, Swiss variant, traditional orthography'), | ||||
|             ('i-mingo', 'Mingo'), | ||||
|             ('kl-tunumiit', 'Tunumiisiut'), | ||||
|             ('nan-hani-tw', 'Hanji'), | ||||
|             ('pl', 'Polish'), | ||||
|         ], | ||||
|     ) | ||||
| @@ -1609,13 +1613,17 @@ class MiscTests(SimpleTestCase): | ||||
|             ('/xyz/', None), | ||||
|             ('/en/', 'en'), | ||||
|             ('/en-gb/', 'en'), | ||||
|             ('/en-latn-us/', 'en-latn-us'), | ||||
|             ('/en-Latn-US/', 'en-Latn-US'), | ||||
|             ('/de/', 'de'), | ||||
|             ('/de-1996/', 'de-1996'), | ||||
|             ('/de-at/', 'de-at'), | ||||
|             ('/de-ch/', 'de'), | ||||
|             ('/de-simple-page/', None), | ||||
|             ('/de-ch-1901/', 'de-ch-1901'), | ||||
|             ('/de-simple-page-test/', None), | ||||
|             ('/i-mingo/', 'i-mingo'), | ||||
|             ('/kl-tunumiit/', 'kl-tunumiit'), | ||||
|             ('/nan-hani-tw/', 'nan-hani-tw'), | ||||
|         ] | ||||
|         for path, language in tests: | ||||
|             with self.subTest(path=path): | ||||
| @@ -1824,7 +1832,7 @@ class UnprefixedDefaultLanguageTests(SimpleTestCase): | ||||
|  | ||||
|     def test_page_with_dash(self): | ||||
|         # A page starting with /de* shouldn't match the 'de' language code. | ||||
|         response = self.client.get('/de-simple-page/') | ||||
|         response = self.client.get('/de-simple-page-test/') | ||||
|         self.assertEqual(response.content, b'Yes') | ||||
|  | ||||
|     def test_no_redirect_on_404(self): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user