#31540: i18n URLs are not matched against the fallback language.
--------------------------------------+------------------------------------
     Reporter:  osxisl                |                    Owner:  nobody
         Type:  Bug                   |                   Status:  new
    Component:  Internationalization  |                  Version:  3.0
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

 * stage:  Unreviewed => Accepted


Comment:

 I'm going to accept this. I think there is an issue. I don't see that we
 can do much about slugs that match the language code regex, here `id-...`
 but the 404 isn't optimal...

 If `id-button` **correctly** falls back to `id` as the langauge code, but
 then tries to match the URL against `id/` — which it doesn't match.

 But either we should use the submitted URL as the prefix, or redirect to
 the fallback URL.

 The `id-button` example seems wrong, but it occurs with `en-us`. That
 would fallback to `en`, except it 404s.

 More details and reproduce on the forum thread here:
 https://forum.djangoproject.com/t/i-get-a-404-error-if-slug-begins-with-
 id/2272/7

 Clean project, enable LocaleMiddleware:

 {{{

 from django.conf.urls.i18n import i18n_patterns
 from django.urls import path
 from django.http import HttpResponse


 def hello(request):
     return HttpResponse("hello")


 urlpatterns = i18n_patterns(
     path("", hello),
     prefix_default_language=True,
 )
 }}}


 `/en/` 200.
 `/en-gb/` 200
 `/en-us/` 404


 {{{
 Using the URLconf defined in ticket_31540.urls, Django tried these URL
 patterns, in this order:
     en/
 The current path, en-us/, didn't match any of these.
 }}}


 So this is because `en-us` isn’t a configured language but when
 determining the language we fell-back to `en` correctly. Then we didn’t
 resolve the URL using the same, or redirect to the fallback language URL.

 It seems like that’s something we should do, or… ? It seems suboptimal.
 (Very happy if someone can correct me as to why not...🙂)

 It seems like the complement of #17734, #27402 &co.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31540#comment:7>
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/064.938cb76eb4ae8bb07641247741cb9d4a%40djangoproject.com.

Reply via email to