#34455: i18n_patterns() not respecting prefix_default_language=False
-------------------------------------+-------------------------------------
     Reporter:  Oussama Jarrousse    |                    Owner:  Mohit
                                     |  Singh Sinsniwal
         Type:  Bug                  |                   Status:  assigned
    Component:                       |                  Version:  4.2
  Internationalization               |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
  internationalization, i18n,        |
  prefix_default_language            |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mohit Singh Sinsniwal):

 * cc: Mohit Singh Sinsniwal (added)
 * status:  new => assigned


Comment:

 Mariusz, sorry for closing it, I went on a different track while solving
 the issue, and now I can replicate.
 I need your help in understanding the middleware. Locale class, what
 should be done with /admin/login/?next=/admin ?


 1. When /admin/login/?next=/admin is requested, it calls
 get_fallback_lanuage and redirects afterward to
 /en/admin/login/?next=/en/admin/
 get_faalback_language is taking the prefixed language. If we dont want
 that, then we can update the process_request function:
 OLD:
     def process_request(self, request):
         urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
         i18n_patterns_used, _ = is_language_prefix_patterns_used(urlconf)
         language = translation.get_language_from_request(
             request, check_path=i18n_patterns_used
         )
         if not language:
             language = self.get_fallback_language(request)
             print('coodddd',language)
         translation.activate(language)
         request.LANGUAGE_CODE = translation.get_language()

 New:
     def process_request(self, request):
         urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
         (
             i18n_patterns_used,
             prefixed_default_language,
         ) = is_language_prefix_patterns_used(urlconf)
         language = translation.get_language_from_request(
             request, check_path=i18n_patterns_used
         )
         language_from_path =
 translation.get_language_from_path(request.path_info)
         if (
             not language_from_path
             and i18n_patterns_used
             and not prefixed_default_language
         ):
             language = settings.LANGUAGE_CODE
         translation.activate(language)
         request.LANGUAGE_CODE = translation.get_language()

 I want to work on this issue and need your suggestion if I am on right
 track.


 Replying to [comment:12 Mariusz Felisiak]:
 > Replying to [comment:11 Mohit Singh Sinsniwal]:
 > > Unable to replicate the bug. For me, it works for both version 4.2 and
 4.1.7.
 > > I used LocaleMiddleware
 >
 > Please don't close already accepted tickets. I'm still able to reproduce
 the issue.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34455#comment:16>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701875771297c-f83e2c5c-0418-4d31-9ef5-9d44a9079b12-000000%40eu-central-1.amazonses.com.

Reply via email to