Forum

Thread tagged as: Question

Making an existing Perch site multilingual

One of my clients wants their English Perch site to add content in Spanish. I've made multilingual sites in Perch in the past using the example here: https://solutions.grabaperch.com/architecture/how-do-i-create-a-multilingual-site, but those were always sites that were planned to be multilingual from the start, in other words, the client added content into both a region-en and region-es region as they built out their site's content.

With this site, with existing content (and quite a bit of it), wouldn't the approach in the example solution necessitate recreating all the existing regions of the site into not only a new region, region-es, but also a new English region, region-en? Is there a workaround so that the existing regions (in English) can remain as is, but only add new -es regions for the Spanish versions?

Thanks!

Franz Neumann

Franz Neumann 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You could make the English suffix empty to get the existing regions.

I was hoping that would be the case. So like this?

<?php
session_start();
$lang = ''; // default lang
switch(perch_get('lang')) {
    case '':
        $lang = '';
        break;
    case 'de':
        $lang = 'de';
        break;
    // add more cases for language options here...

    default: 
        if (isset($_SESSION['lang'])) {
            $lang = $_SESSION['lang'];
        }
        break;
}
$_SESSION['lang'] = $lang;
?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd need a way to switch to English, so:

<?php
session_start();
$lang = ''; // default lang
switch(perch_get('lang')) {
    case 'en':
        $lang = '';
        break;
    case 'de':
        $lang = 'de';
        break;
    // add more cases for language options here...

    default: 
        if (isset($_SESSION['lang'])) {
            $lang = $_SESSION['lang'];
        }
        break;
}
$_SESSION['lang'] = $lang;
?>

Thanks!