Language detection not working

languages
multilang

#1

Hello, I’ve a multi language site which should detect the users language and then redirect to the swedish version (default is EN) if the user is from Sweden.

Here is a testing link: http://testing.ivomynttinen.com/node-site/
Swedish version: http://testing.ivomynttinen.com/node-site/se/

The language selector works fine, but auto detection does not detect swedish at all. I tried to a) browser from swedish IP via VPN, set Chrome language to swedish, set OS language to swedish. None of these things affect the redirection and I always end up on the english site except when I manually choose swedish via the language selector and then come back to the site (I guess in that case a cookie is set).

This is my config:

c::set('languages', array(
  array(
    'code'    => 'en',
    'name'    => 'English',
    'default' => true,
    'locale'  => 'en_US.utf-8',
    'url'     => '/'
  ),
  array(
    'code'    => 'se',
    'name'    => 'Svenska',
    'locale'  => 'se_SE.utf-8',
    'url'     => '/se'
  ),
));
c::set('language.detect',true);

Any ideas how I can make this work?


#2

What is that “node-site” in your URL? Is that a subfolder on the webserver?
Does it work if you run it from the webserver root? :thinking:


#3

Yes, it’s a sub folder. Running on root doesn’t change anything.


#4

What do you get if you print $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?