Forum

Internationalization

Hi,

What's the best way to go about having multiple translations of a page? I'm toying with the idea of using two editable content fields, one for english and another for spanish - for example.

Anyone done this already? Any input or ideas highly appreciated. I'm thinking to just pass the language variable via get, like so:

https://mywebpage.com/?lang=en

Sorry if this is already covered in this forum, I tried to search but nothing came up :-)

Thanks!

Jarl Robert Kristiansen

Jarl Robert Kristiansen 0 points

  • 7 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Jarl, I have just started building a multilingual site and setting the language in a session seemed appealing initially. However it soon got messy and now I think that a branched site is a better overall strategy.

The second option of passing in the language variable was appealing as you only have to create one page and Perch automatically creates two editable regions, Heading - en Heading - es Body - en Body - es This also means that you only need to create one page with dual language sections, so far so good. However, if you start to think about structured content and including nested templates and layouts then option 2 starts getting a bit messy.

For simplicity and flexibility I have found that option 1 works really well. Keeping page templates lean and pulling in shared templates for the content:

  • The pages can just share the same content templates, except for an English header and nav for the en branch and a Spanish header and nav for the es branch.
English Page

<?php 
    include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php');
    perch_layout('global/en/level-1-top');
    perch_layout('global/en/level-1-main-nav');
?>

<div class="uk-container uk-container-center uk-width-medium-4-6">  
  <div class="uk-grid"  data-uk-grid-margin data-uk-grid-match="{target:'.uk-panel'}">
      <?php perch_content('English Content');?>
  </div><!--/grid-->
</div><!-- / end container-->

<?php perch_layout('global/bottom'); ?>


Spanish Page


<?php 
    include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php');
    perch_layout('global/es/level-1-top');
    perch_layout('global/es/level-1-main-nav');
?>

<div class="uk-container uk-container-center uk-width-medium-4-6">  
  <div class="uk-grid"  data-uk-grid-margin data-uk-grid-match="{target:'.uk-panel'}">
      <?php perch_content('Spanish Content');?>
  </div><!--/grid-->
</div><!-- / end container-->

<?php perch_layout('global/bottom'); ?>


The 'English Content' and 'Spanish Content' utilise the same template
  • From an end users point of view it is also a lot less confusing in the admin section as both branches are quite clearly separated, whereas $Lang mixes the en and es sections together, so more chance of confusion and errors.

  • For me it seemed easier to let perch handle the navigation as you go further down a branch.

  • It also allows you to localise a branch for one language that may not be required on the other branch e.g., For a restaurant an explanation of Spanish menu items might be useful in English, but not required in Spanish. This is easy to address in a branched site.

You can also use both methods where it suits.

Note: I am just building my first multilingual site with Perch, so I'm no expert.

Hope this helps

We've also created a site that's currently one language but will be five. We also opted for 'strategy one'. The main reason is that its very clear what pages are what language in the admin area. We decided to keep the languages completely separate. Even though the layout of the pages will be very similar in each language, we could see requirements for selective images changes and there will also be some minor styling changes due to the amount of room some languages need.Large parts of the site design are in the style sheet(s) anyway so we hope we're also catering for future design changes. Can't yet tell if we made the right decision as the site is still only one language at the moment.

Thanks for all the great input, and especially thanks to Andy for sharing the code.

I have decided to scrap my original plan and go with a branched site, as per your recommendations.

Good points there Graham with different content.

And thanks for fetching the link to this in documentation Rachel, should have dug a little further ;-)