Hi!

Scenario: You have translated URLs, e.g. /pricing and /preise (German). Someone 
visiting your page in one language copies a page’s URL (e.g. /preise) and sends 
it to their friend, who uses a different language. The friend will get a 404 
because their language’s URL translation (e.g. /pricing) doesn’t match the 
shared URL.

Possible solution: Find the URL translation in the friend’s language and 
redirect them to that page.

I’ve come up with a quick and dirty implementation of a Django middleware that 
finds the URL using brute-force: 
https://gist.github.com/jonashaag/e37b72f2270cb4038a808fbdbac6a1b9 
<https://gist.github.com/jonashaag/e37b72f2270cb4038a808fbdbac6a1b9>

Question 1: Is there a smarter way to find the correct URL?

Question 2: Do think this could be useful in Django proper? It could easily 
live in a third-party module as well.

Jonas

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/20BDB8DF-BB80-4565-B536-ED160F7DC79C%40lophus.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to