Language specific URL

We’ve built a website with Kirby 3.4 and the Shuffle Theme 2.8

The intention was to have the German version at gesellschaftderzeichen.de the English one at societyofsigns.com.
However, If I do so, the switching of languages won’t work and things start to get buggy.

For now the English website still lives in /en, which is sub-optimal.

    'code' => 'en',
    'default' => false,
    'direction' => 'ltr',
    'locale' => [
        'LC_ALL' => 'en_US'
    ],
    'name' => 'EN',
    'translations' => [

    ],
    'url' => 'https://societyofsigns.com/en'
]; 

I assume this should be possible with Kirby, since it is documented here:

Might this problem be caused by the rather complex template?
Does anyone know how to fix it?

Why is this URL set to en?

Thanks for reading my post.
If I don’t do this, the menu DE | EN won’t switch to English any longer.
Maybe this has to do with how this language-menu is programmed?

<!-- language nav -->
<?php if(page('navbar')->language_links() == 'true'): ?>
<div class="uk-navbar-item uk-visible@<?= page('navbar')->navbarLangVisible() ?> uk-padding-remove-horizontal">
	<ul class="
		uk-padding-remove
		uk-margin-remove
		uk-subnav <?php e(page('style')->languageNavDivider() == "true", 'uk-subnav-divider') ?>
		<?php e(page('style')->languageNavPill() == "true", 'uk-subnav-pill') ?>">
		<?php foreach($kirby->languages() as $language): ?>
		<li<?php e($kirby->language() == $language, ' class="uk-active uk-text-bold"') ?>>
			<a
				class="<?php e(page('style')->languageNavUppercase() == "true", 'uk-text-uppercase') ?> <?= page('style')->languageFontSize() ?> <?= page('style')->languageLetterSpacing() ?>"
				href="<?= $page->url($language->code()) ?>" hreflang="<?php echo $language->code() ?>"
				
				>
				<?php echo $language->name() ?>
			</a>
		</li>
		<?php endforeach ?>
	</ul>
	
</div>
<?php endif ?>

Also, even if the url is on

'url' => 'https://societyofsigns.com'

the website stays German (since default language is German).

I just tested locally and it works as expected with a 3.5.3.1 Starterkit with two languages.

When setting the urls in your language files like they should be, what does your navigation actually render?

Thank you @texnixe for getting on to this. That gives me hope, since you helped my out a lot in the past.
I’ve just set it back to 'url' => 'https://societyofsigns.com'.
The page is rendering in German.
The language-menu is switching the urls but the language stays always German.

Could you please either/and

  1. Test this with a current Kirby version (3.5.3.1)
  2. Test this with a Starterkit (with two languages enabled + the URL rightly set) instead of the theme you use

I want to rule out that we are hunting an issue that has been fixed in the meantime, or something that is related to this theme you are using.

Also, do you (or the theme) use any plugins, custom code etc. that might interfere here?

Dear @texnixe, I will have to figure out a workaround for more tests.
The page is published and I should put to its semi-working state.

The Shuffle Theme has a lot of custom configurations and plugins.

Plug-Ins: autoresize cachebuster editor-gallery-block editor-info-block editor-intro-block editor-table-block k3-image-clip kirby-colors kirby-pagetable kirby-webp kirby3-autoid kirby3-robots-txt lessphp pagemethods resolve similar sitemapper

I will try with a Kirby version 3.5.3.1
Starting over with the Starterkit does not seem an option.

No, of course not, but somehow we have to rule out that it’s due to the theme, a plugin or an outdated Kirby version, and the only good way to test this is with an up-to-date Starterkit.

1 Like

Good morning @texnixe,
I did the tests you recommended.

  • Upgrading the template to 3.5.3.1 breaks the page
    if ($template->exists() === false) {
                  throw new NotFoundException([
                      'key' => 'template.default.notFound'
                  ]);
              }
    
  • I installed the starterkit and used the language-configuration as described in the tutorial. This works fine. The English url displays the page in English, the German url displays German.

Where can I find the exact version of Kirby? This seems to differ from version to version.

Looking for @aristotheme in the forum I found this:

Might this be all related?

Are you sure? That’s something that shouldn’t be done in themes.

I think the issue you posted related to an issue in the Panel, not the frontend?

Is language detection enabled in the config? Could you post the config file, please?

Hi @pixelijn, I will have to double-check that, but remeber seeing something that made come to this conclusion.

I did enable language detection before posting here. But it did not fix the problem.

The config.php seems to be pretty similar to the one posted in the linked thread above.

<?php

return [

    'debug' => true,

    'panel' => [
      'css' => 'assets/css/panel.css'
    ],

    'email' => [
      'transport' => [
        'type' => 'smtp',
        'host' => 'srvc104.turhost.com',
        'port' => 465,
        'security' => true,
        'auth' => true,
        'username' => 'info@yoursite.com',
        'password' => '***'
      ]
    ],

    'smartypants' => true,

    'date'  => [
      'handler' => 'strftime'
    ],

    'languages' => true,

    // Plugin / Automatically resize images on upload.
    'medienbaecker.autoresize.maxWidth' => 1920,

    // Cachebuster
    'schnti.cachebuster.active' => true,

    // converting JPG, JPEG and PNG into much smaller WEBP
    //'mrfd.webp.autoconvert' => true,
  

    // Robots  
    'bnomei.robots-txt.sitemap' => 'sitemap.xml',
    'bnomei.robots-txt.groups' => [ // array or callback
      '*' => [ // user-agent
          'disallow' => [
              '/kirby/',
              '/site/',
          ],
          'allow' => [
              '/media/',
          ]
      ]
    ],

    // Support for language detect option
    '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();
            }
        ]
    ]
      
];

Could you please disable that route in your config as well, then remove the session data and try again.

1 Like

@pixelijn this works! Perfect, thanks you so much :smiley:
Have a great day!