Snippet in a different language

Hello,

I’m new into Kirby and absolutely new into php. I have around 25 pages of static html plus their counterparts in an another language which are ready to publish. I want to integrate a „dynamic“ blog to the site - that’s why I came across Kirby, am still testing it locally and am very fond of it.

I don’t know how to code the snippets in such a way, that the page template finds a snippet according to the specific language.
This is the code for the default language (DE):

<?php snippet('codepageheader') ?>
    <?php snippet('codepagebody') ?>
<?php snippet('codepagefooter') ?>

The template finds the corresponding php snippets. I would like to direct it to codepageheadertr, codepagebodytr, codepagefootertr when the second language is chosen.

I tried putting a line in the languages php file:

‚navigation‘ => ‘codepagenavde’

That did not work.

Can somebody help me further? Thanks in advance,

Nedim

PS: I should probably be able to solve it with routing. But believe me I don’t understand it.

What is your reason for having different snippets in different languages?

What you can do:

<?php
$languageCode = $kirby->language()->code();
if ($languageCode === 'de') {
  $languageCode = '':
}
?>
<?php snippet('codepageheader' . $languageCode) ?> 

Same for the other snippets.

Thanks. I will try that out.
My reason for using different snippets is actually two very complex mega-navigations which are on all pages. They have too much css code + categorizing titles etc. Since the navs in both languages are already coded, it seems easier for me to copy past them into snippets and just change the urls.
Most pages are already finished as html. I want to use the Kirby framework for the blog or news part.

Best,

Nedim

That works like this:

<?php $languageCode = $kirby->language()->code(); if ($languageCode === 'de') ?> <?php snippet('codepagenavtr' . $languageCode) ?> <?php snippet('codepagenav' . $languageCode) ?>

Thank you very much!