Open HappyMiner opened 1 year ago
I just tried again with an empty database, just in case there was something that it does not agree with, no change.
I have made a final attempt before I bury this for good. Created a brand new project according to the documentation. Under "Check the site" it is stated: "In either case, you can view the site in /en/ or /fr/ (no differences yet)." Which is WRONG. The above mentioned redirect also happens in this new base project. If I try to go to http://127.0.0.1:8000/cn/ I get an automatic redirection to http://127.0.0.1:8000/en/cn/ Creating the CN locale in the admin also does not change anything.
I have a local set up of bakerydemo with pretty much the same settings. The only difference I have is RedirectMiddleware is before LocaleMiddleware.
Best to join the Wagtail Slack and ask in #support or #multi-language
I have a local set up of bakerydemo with pretty much the same settings. The only difference I have is RedirectMiddleware is before LocaleMiddleware.
Best to join the Wagtail Slack and ask in #support or #multi-language
Many thanks for your answer! According to the documentation LocaleMiddleware should come BEFORE RedirectMiddleware. If this is incorrect it should be urgently corrected or clarified.
I don't think this is it, I have LocaleMiddleware before RedirectMiddleware on my sites. Everything works as expected.
I didn't think it was it, but was one differece I noticed between my dev setup and the settings shared here. I'm afraid I do not have the capacity to help with this for a while, so Slack is the best bet
@zerolab I'm unable to spare any time for the foreseeable future to help myself too unfortunately
@HappyMiner You're base.py looks fine, it checks with what I've used on other sites I've created. I presume you set up your locales in the admin interface as well? You should see something like this:
And then to view an /en/page with /cn/page, then page needs to be translated from the admin drop down list ... e.g.
Maybe you've done all this already, just wanted to double check.
I have a sandbox project for testing various bits of codes, it's set up with 4 languages and working as expected. Feel free to clone it or look at the set up to check it out. https://github.com/enzedonline/testlocalize
@enzedonline Thank you for your answer. Yes, I also did the translations in the admin section from the beginning. No change. Yesterday I found that when following along the general Wagtail docs I encounter the same issue (without using wagtail_localize). So my guess is that the redirecting functions ("django.middleware.locale.LocaleMiddleware", and / or "wagtail.contrib.redirects.middleware.RedirectMiddleware",) must have issues. I mean there isn't really anything I can misconfigure when following the tutorials... Especially on a brand new project as described in the docs.
I think this is far more likely something to do with your local environment (either local or global) since it works as described in the docs for others.
I have several wagtail-localize sites using different locale sets, on mtiple platforms. Never seen this issue before.
If you try the site I linked to earlier and it doesn't work in your environment then that's where I'd be looking to see what doesn't square up.
@HappyMiner have you tried the advice from https://github.com/wagtail/wagtail-localize/issues/683#issuecomment-1489974737 ?
Using
Django 4.1.7 Python 3.10.6 wagtail 4.2 wagtail_localize 1.5
redirections to a second language are broken.
Opening http://127.0.0.1:8000/ correctly redirects to http://127.0.0.1:8000/en/ however, when I click "live view" in the admin for the Chinese version of my page I am being redirected to http://127.0.0.1:8000/en/cn/ which is obviously wrong. I searched online for 2 days without finding any explanation or solution.
Steps to reproduce
Follow the steps in the documentation: https://www.wagtail-localize.org/ https://www.wagtail-localize.org/tutorial/2-configure-wagtail-localize/
My files for reference
urls.py
base.py