Unexpected result when linking pages in a multi-lingual site

Hey everyone,

I was wondering what the best way is to link pages. If I enter this text into the secondary language file, in my case german:

(link: projekte/projekt-a)
(link: projects/project-a)

I get the following result:

http://localhost:8888/projekte/projekt-a
http://localhost:8888/de/projekte/projekt-a

In case of the german URL-Keys (projekte/projekt-a), the /de is missing from the generated link. In case of the english URL-Keys (projects/project-a) which is also the uid of the page, the correct german link is generated.

A solution is of course to use only the default language URL-Keys when linking pages, but for clients, this might not be very intuitive. Do you guys know of a solution to this problem?

Thanks, Steffen

Yes, I’m afraid you have to either use the uid of the page or add the language code in front:

(link: de/projekte/projekt-a)

Thank you @texnixe!

I made a small custom field to display the page-id in the panel. In case anybody is interested:

<?php

class IdField extends BaseField {

  public $text;

  public function result() {
    return null;
  }

  public function content() {
    return '<div style="padding:.5em;font-size:1em;line-height:1.5em;font-weight:400;border:2px solid #ddd;background:#fff;">'
    . $this->page()->id() . '</div>';
  }

  public function element() {
    $element = parent::element();
    $element->addClass('field-with-icon');
    return $element;
  }

}