Multilingual Websites

Oncord websites can be programmed to support multiple languages by having a page tree for each language.

In this example, we will create a bilingual website for English and French.  You can repeat the steps below for each additional language you wish to add.  

Create the Page Trees
To start, create a page tree for each language.  Go to Website > Pages, and create /en/ for English and /fr/ for French.  The pages for each language should sit underneath.

Tip: You can use the right click "Clone" feature to copy a page from one language to another.

Redirect the Home Page
Because the home page now sits at either /en/ or /fr/ we can redirect the root domain's home page to one of the languages.  

Edit the root home page, click Source, and in the PHP tab add:

<?php \Framework\HTTP\Redirection::redirect('/en/'); ?>

Setup the Designs
You will want to have two designs, one for each language.  Clone your design under Website > Designs.

Edit your pages and change their design to the corresponding design.

Add PHP to Designs
Under the PHP tab, add the following code snippet to get the link for the languages used in the next step:

<?php function getLinkForLanguage($strLanguage) { $strPage = \Components\Website\Pages::currentPageId(); $strPage = '/' . $strLanguage . '/' . substr($strPage, 4); while (!\Components\Website\Pages::get($strPage)) { $strPage = substr($strPage, 0, strrpos($strPage, '/', -2)+1); } return $strPage; } ?>

Link to the Languages
In the header of your design, or wherever you would like your user to be able to pick their language, add the following code to link to the page in the corresponding language sitemap.

<a href="[? getLinkForLanguage('en') ?]">EN</a> | <a href="[? getLinkForLanguage('fr') ?]">FR</a>

The result will look similar to:

Primary Navigation

For primary navigation, you can set the rootpage attribute to rootpage="/en/" and rootpage="/fr/"

You cannot change the 'system default' pages to be in a different language.
This includes customer profile pages, ecommerce categories and the checkout process.