Open afbora opened 2 years ago
This issue is only reproducible for some languages, we've tested following languages:
Ha, it almost looks like only $language <= "en"
can have a root url.
That's super weird...
Ha, it almost looks like only $language <= "en" can have a root url.
Is it just en
or is it en
and de
from your test, @afbora @adamkiss?
@distantnative I'm not involved, I just noticed it looks like it's broken alphabetically.
@distantnative EN is always the secondary language in manual tests. Only DE passed the test when we changed the primary language.
I think I am getting to the source of the problem, without quite knowing yet how to solve it:
http://sandbox.test/en/not-there
$this->next()
to jump to fallback routes https://github.com/getkirby/kirby/blob/main/src/Cms/LanguageRoutes.php#L47not-there
for the secondary language English does not find a page and falls back to looking for the path en/not-there
in the French primary language. Which also can't be found - but since we are looking now in the French context, the French error page gets rendered.On the one hand, I see how we thought a fallback to also check for a page en/not-there
in the /
context would make sense. But it doesn't quite when we already checked for not-there
in the /en
context. It creates parallel universes :D
This is why right now the secondary-language error page cannot really be reached. I didn't check for German, but I would be surprised if that one is actually working either.
I looked into this again. I am not sure we can solve this:
/
next
if nothing is found (e.g. also to support custom routes that aren't set up by LanguageRoutes but share the prefix)en/foo
matched for the secondary language English, didn't find the page, moves on and now matches the pattern for the primary language French route because it has no prefix. Now as en/foo
full path. And thus the language is set to French and if no page is found, it's the French error page.I see two options, both not sure how to implement yet: a) We implement a way where we don't move to the next route, but skip all other language routes while not skipping all other routes. b) We find a way how a language without URL prefix cannot match any path that would match any other language.
Scenario to reproduce:
Have 2 languages:
"url" => "/"
"url" => "en"
If you visit
/en/asdf
, the url is right, but the content is not translated (appears in default language). If you visite/asdf
, the url is right and the content is translated.Fix: If I set the french
url => "fr"
, it works as intended. Both "/" and "/en" are displaying the right locale. If I set the english as default, withurl => "/"
, it works as intended.This means I cannot have French as default language with
url => "/"
.Same issue as this user: https://forum.getkirby.com/t/error-page-is-shown-in-wrong-language/18084/9
Originally posted by @juliencharette in https://github.com/getkirby/kirby/issues/2609#issuecomment-1306071201