Hi there,
I hope everbody is ok in this strange times.
I know my question is similar to this post:
I made a multilingual website with French by default and English as secondary language. I set the generic config.php with languages.detect as stated by the documentation but it doesn’t work (tested by friends with English browers, by me with a language switcher Firefox add-on, with deleted cookies and private mode.
The documentation on this point just say to add this option so I don’t really now how to test it further or knowing if I did the good thing.
Did I miss something?
and I’ve read the Github Issue:
opened 04:58PM - 15 Jul 19 UTC
closed 09:16PM - 07 Mar 20 UTC
type: bug 🐛
**Describe the bug**
When setting `'languages.detect' => true` in the config, t… he user is only redirected to the detected browser language if the `url` parameter in the default language's config file is set to the default `null` (or language code) setting, not if the setting is `'url' => '/'`
**To Reproduce**
Steps to reproduce the behavior:
1. Define two languages (via the Panel or manually), set `'url' => '/'` for the default language
2. Set `'languages.detect' => true` in the config
3. Set your preferred browser language to the non-default language
4. See how you are **not** redirected to the detected language
**Expected behavior**
In an ideal world, redirection to the detected language would also work if the default language omits the language code.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Kirby Version**
3.2.2 (and most probably older versions as well)
But may problem is that my client doesn’t accept the solution. They insist on not having the default language code (en in this case) in the URL. And they have a childish, but in my eyes valid point, since it’s a Kirby2 update - it worked with the old one. I know the Github Issue is closed but I need a solution. Only thing I came up is to check the detected language, send the visitor to the right translation and store it in a session. But I think this is not best way to handle this.
Is there any other way, maybe a route, how this can be handled?
thanks
tom
You can handle with session on routing, for example: Language.detect does not work
Oh, I guess I haven’t seen this…
Thanks, works like charm
I haven’t tried it, but I’m glad it worked
I still think this should work by default, but at least the client is happy now.
Thanks again and have a nice day
tom
mungle
September 15, 2020, 3:26pm
6
This doesn’t works for me.
In my config.php I have:
return [
'debug' => true,
'languages' => true,
'languages.detect' => true,
In my it.php :
return [
'code' => 'it',
'default' => true,
'direction' => 'ltr',
'locale' => ['LC_CTYPE' => 'it_IT'],
'name' => 'Italiano',
'url' => '/'
];
in my en.php :
return [
'code' => 'en',
'default' => false,
'direction' => 'ltr',
'locale' => ['LC_CTYPE' => 'en_US'],
'name' => 'English',
'url' => 'en'
];
If in it.php I change 'url' => null
I get www.example.com/it
If I add the routing code suggested nothing change… do you see something wrong in my configuration?
Thanks