I read all the questions regarding not working language detection but couldn’t find any solution.
So the browser seems to always use the language set as ‘default’ = > true (in my case English) when I change it to German the website always opens up in German. The strange thing is when I use <?php echo $site->detectedLanguage() ?> it always gives me back the correct language of the system. So why is the language result from detectedLanguage() different from c::set(‘language.detect’, true); ? And how can I make it work to display the language of the OS language which is visiting my site?
Kirby stores a cookie to remember the correct language. If you switch from one language to the other and try to test if language detection works, you first have to delete the cookie first.
I have done that, for example on the iPhone deleted all website data under settings and in the advanced menu and also blocked cookies. But I still only get the English version displayed on that device. Any other idea?
anyone another idea? I meanwhile tried my page on other completely new computers too with the same result, it does not switch to e.g. German when OS is German.
Unfortunately, I can’t reproduce this on my local dev server, will try again with a remote site as soon as I get round to it. But let’s see what @lukasbestle can contribute to this issue, Lukas?
What OS / Browser did use? From experience Internet Explorer needs to be told the language, but firefox / chrome etc do not (uses the OS language)…i hope i got that the right way round! I’ve had problems with things like javascript datepickers showing US date formats in internet explorer but showing correctly in UK format Firefox on the same machine & browser.
I know thats not really your issue, but my point is different browsers and operating systems report languages differently, and its a tricky thing to detect.
I used to use Chrome. But now I use for testing my Macbook (set to English) and iPhone (set to German) and I delete browser data and cookies every time. I also tried it on Kirby user @mauricehh website: https://maurice-renck.de and there it works pretty fine with my setup (Macbook gets the EN and iPhone the DE site) (invited him to the talk already).
I haven’t set anything server wise (sorry it’s my first multi-language project) is there a good place to get into it? The website is www.myvita.digital/
Yes I think it’s I need to activelly request the browsers language with $_SERVER[‘HTTP_ACCEPT_LANGUAGE’] that’s a god hint already - I’ll let you know.
I didn’t set anything special, my lang-setup looks similar to yours, beside that German is my default option. I had some problems with older version of kirby, where I needed to do some magic, but since Kirby 2 that wasn’t necessary anymore.
If you have access to your servers logfile settings, you could try to configure your access log, so that it shows the detected language of the user-agent (if it doesn’t already). Maybe this will help you figuring out the cause of your problem.
Just wanted to let you know with a fresh Kirby install the language detection works fine locally (tested it with the Chrome add-on and when switch to DE the DE site get’s display and switching to EN the EN site is displayed, cookies need to be deleted before testing of course). Currently I don’t know what’s wrong with my setup, same version, same config file …
Have you had a chance to test the Starterkit on the server as well? Or does the original site work locally? Just to make sure it’s not related to any server settings.
Have you checked if you are using any redirects/routes anywhere (.htaccess/config.php/httpd config file)?
Guys, I just wanted to let you know that it works now but I don’t actually know why. I have installed the Starterkit on the same server to be sure it’s not any server related config. This worked great. I tried then to replace step by step a few files from the Starterkit to my project, started with the config.php, removed all widgets and plugins and also removed the site/cache. In the end however I have used the originale files from the project and then it worked (without any changes to the project files). Anyway, for everybody having problems with this checking if the Starterkit works was a good idea to start with