Forum
Multi Language Template Page
I am currently building a site which allows admins to add content in both English and Welsh.
I've followed the instructions here - https://docs.grabaperch.com/perch/building/how-do-i-create-a-multilingual-site/ to make duplicate content areas like so - <?php perch_content('Description Text - '.$lang)?>
The page is a template however and the end user will be adding many pages at a time. When they add the page through the perch admin panel, they can only see the English language areas when they go-to-and-refresh the page. Then they have to switch to the Welsh version of the site and do the same again.
Is there any way to pass through both language options to the template when it is created so they don't need to refresh the page? Or even if they only have to do it once - that would be fine!
Found my own solution to doing this, possibly not the most elegant - but it works!
At the top of the template page file there is this statement
<?php include($_SERVER['DOCUMENT_ROOT'] . '/app/perch/lang_support.php'); ?>
The code contained within is this, taken from the multilingual site docs reference page :
Then, back to my template page, I have this section at the very top of the page
and further down the page, where the text needs to be rendered, a plain old fashioned php if statement:
The language can then be switched by adding a
?lang=cy
or?lang=en
to the end of the URL