Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this package support Django 2^ ? #42

Open
kentuck13 opened this issue Apr 16, 2018 · 5 comments
Open

Does this package support Django 2^ ? #42

kentuck13 opened this issue Apr 16, 2018 · 5 comments

Comments

@kentuck13
Copy link

Question on title

@Sharpek
Copy link

Sharpek commented Dec 6, 2018

@ton77v
Copy link

ton77v commented May 31, 2019

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

@astagi
Copy link

astagi commented Aug 26, 2019

@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 ;)

@ton77v
Copy link

ton77v commented Aug 28, 2019

@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

@skabbit
Copy link

skabbit commented Jan 16, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants