Multi language setup Kirby 3

Hi,

I am trying to integrate multi language in a project.
For some reason if I create a new blog it happens to fill the exact same content for the other language. So if I don’t change the other language this blog show up on both languages.

You would say this should remain empty until you fill a specific language.

Does anybody know how to fix this? Or is it a normal behaviour?

Thanks!

Thank you!
So I could filter articles in my controller:

 <?php

return function($page) {

  // fetch the basic set of pages
  $articles = $page->filter(function ($child) {
  return $child->translation(kirby()->language()->code())->exists()->sortBy('date', 'asc')->flip();

  // fetch all tags
  $tags = $articles->pluck('tags', ',', true);

  // add the tag filter
  if($tag = param('tag')) {
    $articles = $articles->filterBy('tags', $tag, ',');
  }

  // apply pagination
  $articles   = $articles->paginate(9);
  $pagination = $articles->pagination();

  return compact('articles', 'tags', 'tag', 'pagination');


};

Yep, you can filter in the controller, but don’t put that return there at the top, because that will then return control to the template at that point without running through the rest of the code.

Something like this?

$articles = $page->filter(translation(kirby()->language()->code())->exists()->sortBy('date', 'asc')->flip();

Edit: can’t get it working

The problem here is that you are trying to filter a single page instead of the children of the page, which is not possible.

So it should be:

$articles = $page->children()->filter(function ($child) {
  return $child->translation(kirby()->language()->code())->exists();
});
1 Like

Thank you! @texnixe. It helps me a lot to understand how this works.

Thanks

For single pages, you can either filter the language switcher or gray out links to non-existing translations, or use routes to redirect to the error page/start page.

1 Like