Multilingual paragraph


#1

Hi, I set my website to work with a different page depending on the website.
However, for some part, I need to echo all the languages (en, nl, fr). How could I do something like this :

	<?php echo $page->description()->kirbytext()->language('fr') ?>
	<?php echo $page->description()->kirbytext()->language('en') ?>
	<?php echo $page->description()->kirbytext()->language('nl') ?>

Thanks ! :slight_smile:


#2

Should be :

<?php foreach($site->languages() as $language): ?>
    <?php echo $page->content($language->code())->description()->kirbytext(); ?>
<?php endforeach; ?>

#3

Thanks a lot ! :slight_smile:


#4

Oh, another question,

do you know how to put a class for each language ?
Because now, they are all together… :slight_smile:


#5

You have to wrap the echo with any tag you’d like, for example :

<?php foreach($site->languages() as $language): $code = $language->code(); ?>
    <div class="description-<?php echo $code ?>">
        <?php echo $page->content($code)->description()->kirbytext(); ?>
    </div>
<?php endforeach; ?> 

Will echo the classes description-en, description-fr, etc.


#6

Oh yeah, easy ! haha

thanks a lot !