Open kentuck13 opened 6 years ago
Is it possible to get the same functionality using i18n_patterns:
settings.SOLID_I18N_USE_REDIRECTS = True. In that case, for root paths (without prefix), django will try to discover user preferred language. If it doesn't equal to default language, redirect to path with corresponding prefix will occur. If preferred language is the same as default, then that request path will be processed (without redirect).
The problem is that if you make prefix_default_language=False, the redirect won't happen at all whatever language user prefers. I was so glad when found this package until discovered it doesn't work in Django 2
@ton77v try this one https://github.com/lotrekagency/djlotrek/blob/master/djlotrek/middleware/locale.py
It's a WIP and I've tested it only with prefix_default_language=False
This is how it works: if you don't have any language setting in session, it will use the browser language, otherwise it redirects you to the language you set. If you want to change the main language, you have to switch language manually.
Let me know if it works for you ;)
@astagi thanks! looks good, hadn't chance to test it yet because I solved the problem long time ago with some hacks, and to be straight I don't want to touch that part of the code... for a while 😀
will test the next time when will have a chance
@ton77v try this one https://github.com/lotrekagency/djlotrek/blob/master/djlotrek/middleware/locale.py
It's a WIP and I've tested it only with
prefix_default_language=False
This is how it works: if you don't have any language setting in session, it will use the browser language, otherwise it redirects you to the language you set. If you want to change the main language, you have to switch language manually.
Let me know if it works for you ;)
I think, this isn't correct. With prefix_default_language=False
root prefix /
turns on default_language and doesn't respond to user browser settings. I've just checked it on Django 2.2.
Question on title