Language URL in language config PHP file ignored?

Hello!

I’m running this website

krickelkrackel.com

and I’m running into an issue with Google correcting “Krickelkrackel”, when people search for it (if they do? ;)) into “Krickelkrakel” (the ‘correct’ German writing of this nonsense word). So I’m creating a fantasy locale “kr” as a SEO measure, where all occurances of “Krickelkrackel” are turned into “Krickel-Krakel”. Fine!

I created the language, I updated the content for it, and I set

krickel-krakel.com

up to serve my Kirby installation. I added this as the kr.php language config:

<?php

return [
    'code' => 'kr',
    'default' => false,
    'direction' => 'ltr',
    'locale' => [
        'LC_ALL' => 'kr'
    ],
    'name' => 'Krakel',
    'translations' => [

    ],
    'url' => "https://www.krickel-krakel.com"
];

My main config.php is this:

<?php

return [

    // https://getkirby.com/docs/reference/system/options/panel#custom-panel-css
    'panel' => [
      'css' => 'assets/css/panel.css'
    ],

    // https://getkirby.com/docs/reference/system/options/languages
    //'debug' => true,
    'languages' => true,
    'languages.detect' => true,

    // https://getkirby.com/docs/reference/system/options/smartypants
    'smartypants' => true,

...

So language detect is on (which I’d like to keep) - but also when I turn it off, it doesn’t serve my new ‘kr’ language from the krickel-krakel.com domain.

Any ideas are appreciated! :slight_smile: Thank you!

I made some further experiments, now I’m trying to have

www.krickel-krakel.com

to be the domain for the DE site:

<?php

return [
    'code' => 'de',
    'default' => false,
    'direction' => 'ltr',
    'locale' => [
        'LC_ALL' => 'de_DE'
    ],
    'name' => 'Deutsch',
    'translations' => [

    ],
    'url' => "https://www.krickel-krakel.com"

];

and

krickelkrackel.com

for the EN site:

<?php

return [
    'code' => 'en',
    'default' => true,
    'direction' => 'ltr',
    'locale' => [
        'LC_ALL' => 'en_US'
    ],
    'name' => 'English',
    'translations' => [

    ],
    'url' => 'https://www.krickelkrackel.com'
];

and I removed the domain for the (fantasy) KR language for now:

<?php

return [
    'code' => 'kr',
    'default' => false,
    'direction' => 'ltr',
    'locale' => [
        'LC_ALL' => 'kr'
    ],
    'name' => 'Krakel',
    'translations' => [

    ],
    'url' => NULL
];
    //'url' => "https://www.krickel-krakel.com"

… to no luck, all sites serve the EN version for some reason. The /de paths don’t work either, for some reason…

Again, any ideas would be highly appreciated! Thank you!

(Should I try to delete the KR language entirely for now?)

I think so, yes. Might even have unwanted side effects, since kr is an official language code?

Ok, I did delete the kr.php file – with language detection switched off, it’s still serving the EN version from the “DE” domain, krickel-krakel.com - do you have any other ideas? Thank you so much!

That’s weird.

But what I also notice it that clicking on a link sends me to https://www.krickelkrackel.com/the-idea instead of remaining on the same site. Something seems to be wrong in the setup

Got it! I had this left in my config.php:

// Support for language detect option https://getkirby.com/docs/guide/languages/introduction#automatic-language-detection
'routes' => [
  [
      'pattern' => '/',
      'action'  => function () {
          $session = kirby()->session();

          if ($session->get('languages.detect', false) === false && option('languages.detect') === true) {
              $session->set('languages.detect', true);

              return kirby()
                  ->response()
                  ->redirect(kirby()->detectedLanguage()->url());
          }

          return page();
      }
    ]
],

Removing it caused the odd behaviour to stop, and now it works nicely. Thank you! :slight_smile: