diff --git a/django/middleware/locale.py b/django/middleware/locale.py
index 65a3893..0b32d78 100644
a
|
b
|
class LocaleMiddleware(MiddlewareMixin):
|
37 | 37 | |
38 | 38 | if response.status_code == 404 and not language_from_path and i18n_patterns_used: |
39 | 39 | language_path = '/%s%s' % (language, request.path_info) |
| 40 | if i18n_patterns_used and not prefixed_default_language and str(language) == str(settings.LANGUAGE_CODE): |
| 41 | language_path = '/%s' % (request.path_info) |
40 | 42 | path_valid = is_valid_path(language_path, urlconf) |
41 | 43 | path_needs_slash = ( |
42 | 44 | not path_valid and ( |
… |
… |
class LocaleMiddleware(MiddlewareMixin):
|
44 | 46 | is_valid_path('%s/' % language_path, urlconf) |
45 | 47 | ) |
46 | 48 | ) |
47 | | |
48 | 49 | if path_valid or path_needs_slash: |
49 | 50 | script_prefix = get_script_prefix() |
50 | 51 | # Insert language after the script prefix and before the |
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index 717150d..d82cec2 100644
a
|
b
|
class UnprefixedDefaultLanguageTests(SimpleTestCase):
|
1839 | 1839 | with self.assertRaisesMessage(AssertionError, "Unexpected kwargs for i18n_patterns(): {'foo':"): |
1840 | 1840 | i18n_patterns(object(), foo='bar') |
1841 | 1841 | |
| 1842 | def test_404_page_no_default_language_redirect(self): |
| 1843 | response = self.client.get('/non-existent-page', follow=False) |
| 1844 | self.assertEqual(response.status_code, 404) |
| 1845 | |
1842 | 1846 | |
1843 | 1847 | @override_settings( |
1844 | 1848 | USE_I18N=True, |
diff --git a/tests/i18n/urls_default_unprefixed.py b/tests/i18n/urls_default_unprefixed.py
index 8cadbfa..439234a 100644
a
|
b
|
from django.utils.translation import ugettext_lazy as _
|
5 | 5 | |
6 | 6 | urlpatterns = i18n_patterns( |
7 | 7 | url(r'^simple/$', lambda r: HttpResponse(_("Yes"))), |
| 8 | url(r'^(?P<group1>.+)/(?P<group2>.+)/$', lambda r: HttpResponse(_("Group1-Group2"))), |
8 | 9 | prefix_default_language=False, |
9 | 10 | ) |