Forum
Implementing a Language Selector
I am following this guide - https://solutions.grabaperch.com/architecture/how-do-i-create-a-multilingual-site and choosing to go down the route of Strategy two to create French regions within the site but I am getting confused about its installtion.
- So I started off by making an include file with this PHP code and including it on the page:
<?php
session_start();
if (isset($_GET['lang']) && $_GET['lang']!='') {
$lang = $_GET['lang'];
$_SESSION['lang'] = $lang;
}elseif (isset($_SESSION['lang'])){
$lang = $_SESSION['lang'];
}else{
// default language
$lang = 'en';
}
?>
- Then I created two separate regions on the page:
<?php perch_content('Main content - '.$lang); ?>
<?php perch_content('Main content - '.$lang='fr'); ?>
- Logged into Perch and filled in both regions with relevant content.
My problem is that when viewing the page the regions seem to duplicate themselves:
- Regular: https://aurelie-art.co.uk/
- English: https://aurelie-art.co.uk/index.php?lang=en
- French: https://aurelie-art.co.uk/index.php?lang=fr
I did consider Strategy one for this website although wouldn't you have to have two separate Perch websites running on two different databases? There editing content would be a pain in the bum.
As I have little experience with PHP I am struggling. Can anyone advise me on a solution?
You don't need both of these:
the whole point is that it's dynamic. Use this instead:
Thanks Drew, I knew it was something small.