# Problem with language.detect

**URL:** <https://forum.getkirby.com/t/problem-with-language-detect/1456>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 26, 2015, 4:55am UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456 "2015-06-26T04:55:22Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sciscitator](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sciscitator/32/697_2.png) [@Sciscitator](https://forum.getkirby.com/u/Sciscitator)\
**Post date:** [June 26, 2015, 4:55am UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/1 "2015-06-26T04:55:22Z")

</div>

Hello all,

has anyone successfully setup the automatic language detection?

I’ve set

```
c::set('language.detect', true);

```

and the language configuration is pretty standard:

```
c::set('languages', array(
    array(
    'code' => 'de',
    'name' => 'DE',
    'locale' => 'de_DE',
    'url' => '/de',
  ),
  array(
    'code' => 'en',
    'name' => 'EN',
    'default' => true,
    'locale' => 'en_US',
    'url' => '/en',
  ),
));

```

With this configuration only the first page view redirects correctly from [url.com](http://url.com) to [URL.com - MediaOptions](http://url.com/de). As soon as Kirby has set its cookie all following page views redirects to [URL.com - MediaOptions](http://url.com/en).

What can cause this behavior? Is this a known bug or am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![Sciscitator](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sciscitator/32/697_2.png) [@Sciscitator](https://forum.getkirby.com/u/Sciscitator)\
**Post date:** [July 1, 2015, 4:14am UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/2 "2015-07-01T04:14:06Z")

</div>

Still trying to find a solution. No one on this?

---

<div class="post-metadata">

**Author:** ![mbochynski](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mbochynski/32/728_2.png) [@mbochynski](https://forum.getkirby.com/u/mbochynski)\
**Post date:** [July 4, 2015, 6:59pm UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/3 "2015-07-04T18:59:15Z")

</div>

This is working fine for me. I have set langiage detect after languages array.

```auto
c::set('languages', array(
  array(
    'code' => 'no',
    'name' => 'Norwegian',
    'default' => true,
    'locale' => 'no_no',
    'url' => '/'
  ),
  array(
    'code' => 'pl',
    'name' => 'Polski',
    'locale' => 'pl',
    'url' => '/pl'
  ),
));

c::set('language.detect', true);

```

Everything working fine for me.

---

<div class="post-metadata">

**Author:** ![JanStieler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/janstieler/32/15642_2.png) [@JanStieler](https://forum.getkirby.com/u/JanStieler)\
**Post date:** [July 5, 2015, 4:29pm UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/4 "2015-07-05T16:29:39Z")

</div>

@Sciscitator you have to much commatas in your script on ‘url’.

Cheers,  
Jan

---

<div class="post-metadata">

**Author:** ![mbochynski](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mbochynski/32/728_2.png) [@mbochynski](https://forum.getkirby.com/u/mbochynski)\
**Post date:** [July 8, 2015, 8:31pm UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/5 "2015-07-08T20:31:50Z")

</div>

I’m afraid it is not the case. It is in documentation with the last comma and it was working for me just OK.

---

<div class="post-metadata">

**Author:** ![JanStieler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/janstieler/32/15642_2.png) [@JanStieler](https://forum.getkirby.com/u/JanStieler)\
**Post date:** [July 9, 2015, 10:35am UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/6 "2015-07-09T10:35:50Z")

</div>

Hi,  
okay you are right. I tested it with different commatas and everything worked fine.  
Also the position, if before or after the arrays of language.detect, is equal.  
Have you set your content files also with the right naming?

> **default.de.txt** and **default.en.txt**

---

<div class="post-metadata">

**Author:** ![Sciscitator](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sciscitator/32/697_2.png) [@Sciscitator](https://forum.getkirby.com/u/Sciscitator)\
**Post date:** [July 10, 2015, 3:25am UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/7 "2015-07-10T03:25:33Z")

</div>

@JanStieler:  
Exactly, the syntax is fine even with commata. Also the content files are setup correctly. And the translation itself works perfectly. It’s just the odd behaviour of the language detection.

---

<div class="post-metadata">

**Author:** ![Sciscitator](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sciscitator/32/697_2.png) [@Sciscitator](https://forum.getkirby.com/u/Sciscitator)\
**Post date:** [July 10, 2015, 3:50am UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/8 "2015-07-10T03:50:54Z")

</div>

@mbochynski  
Maybe I’m just getting it wrong, but I cannot see how your configuration would work properly. Aren’t you taking away the possibility for users to choose the language by themselves this way?

You have defined “/” as entry point to Norwegian and “/pl” for Polski. Even if the detection only takes place at the base url, users from Poland couldn’t choose the Norwegian version because the site would always redirect them to the version in Polski. Is this the behavior you want to achieve?

For me language detection would only make sense with the following assumptions:

- Detection only comes in action on the base url of the site
- As shown in my example all language versions of the site are accessable by the language code in the url.

This way it should be possible to use language detection AND let the users change the language by using a language switcher. I think this is a common and adequate way to integrate language detection ([microsoft.com](http://microsoft.com) is doing it this way for example).

Any thoughts on this? Can anyone tell me how the language detection in Kirby actually really works?

---

<div class="post-metadata">

**Author:** ![bastianallgeier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bastianallgeier/32/7569_2.png) [@bastianallgeier](https://forum.getkirby.com/u/bastianallgeier)\
**Post date:** [July 10, 2015, 10:19am UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/9 "2015-07-10T10:19:06Z")

</div>

Do you use the latest version? There was a minor bug in the detector in 2.0.6 which should be fixed now.

---

<div class="post-metadata">

**Author:** ![danielguillan](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/danielguillan/32/766_2.png) [@danielguillan](https://forum.getkirby.com/u/danielguillan)\
**Post date:** [July 16, 2015, 4:01pm UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/10 "2015-07-16T16:01:52Z")

</div>

> [@Sciscitator](#):
>
> This way it should be possible to use language detection AND let the users change the language by using a language switcher. I think this is a common and adequate way to integrate language detection ([microsoft.com](http://microsoft.com) is doing it this way for example).
> 
> Any thoughts on this? Can anyone tell me how the language detection in Kirby actually really works?

This is exactly how I expect language detection to work. But I think something isn’t quite working right. Detection fails on successive visits.

I’ve reported the issue here: [[Panel] Add auto-save not only on blur, but every X seconds · Issue #268 · getkirby/kirby · GitHub](https://github.com/getkirby/kirby/issues/268)

---

<div class="post-metadata">

**Author:** ![Sciscitator](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sciscitator/32/697_2.png) [@Sciscitator](https://forum.getkirby.com/u/Sciscitator)\
**Post date:** [July 16, 2015, 4:34pm UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/11 "2015-07-16T16:34:44Z")

</div>

Thanks for the answer. I’m using 2.1.0 from 19.5. Will update to latest commit and will try again.

---

<div class="post-metadata">

**Author:** ![jonabaptistella](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jonabaptistella/32/5797_2.png) [@jonabaptistella](https://forum.getkirby.com/u/jonabaptistella)\
**Post date:** [October 27, 2016, 7:54pm UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/12 "2016-10-27T19:54:47Z")

</div>

Hey, I know that this is a old issue but I tried to get the language kit from kirby (clean install) to reflect what my issue is.

I have tested again and again with and I do not get this to work. So I have cleaned the cache and also I have only used Firefox for my tests. The issue is consistent.

###So my issue:

The languages detect worked fine until I added the third language Portuguese. With english and Norwegian it worked. Then I added the last language, then the automatic switching stops not working. Also when I then try to go back it does´t work anymore.

Any ideas of what causes this?

Here is my test repo: [https://github.com/jonabaptistella/lang.curto.dk](https://github.com/jonabaptistella/lang.curto.dk)

I really need this to work perfectly. This is with Language-kit from Kirby 2.3.2.

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 4:54pm UTC](https://forum.getkirby.com/t/problem-with-language-detect/1456/13 "2025-02-06T16:54:54Z")

</div>

Archived on February 6, 2025, 4:54pm UTC


