Module: Multilingual content

2 of 6 Pages

Explore languages in Xperience

Offering your website content in multiple languages is an important step in reaching a broader audience. To provide a better and more inclusive user experience for your visitors, Xperience by Kentico supports localization and language variants.

Preparing different language versions of your content is a task for the editors. However, development effort is required to properly set up different language support in your website.

Multilingual content series

This is the first part of the Set up multilingual mini-series. Using a simple concrete example, the mini-series demonstrates best practices and necessary steps you need to perform in order to present your website content in multiple languages in a user-friendly way.

In this section, you will learn:

  • the basic terminology related to multilingual support in Xperience by Kentico.
  • how to display your home page and cookie consents in two language versions: English and Spanish.

screen recording gif that demonstrates language switching by URL

This section focuses on the developer tasks of the process, but it also references actions editors will typically take. Feel free to follow those steps as well to see and enjoy the fruits of your effort at the end. 🙂

Prerequisites

To follow along, you should have the following:

The main branch of this repository is a good starting point that has all of the above set up. You will find the instructions to run in the README file.

Additionally, we assume you have followed Create a cookie preferences widget guide and Build a tracking consent banner guide (or implemented your own cookies widget and tracking consent banner in a similar way.) The widget and tracking consent banner you will be working with should look like this:

screenshot of cookie consent page

If you prefer to see the finished implementation of multilingual right away, take a look at the finished branch of our repository. It contains both the cookie widget and tracking consent banner.

Understand languages in Xperience by Kentico

Before diving in, let’s get familiar with the basic concepts of working with languages in Xperience by Kentico.

Languages are defined in the administration interface using the Languages application.

When more than one language is defined, editors can create multiple language variants of website channel pages, content items, and consent texts (one variant per language).

One language must always be set as a default language.

Default language in Xperience by Kentico

For example, if the default language is English, any content items editors create are, by default, English language variants. Editors can create a different language variant by manually picking a different language.

A fresh install of Xperience by Kentico boilerplate project, comes with English pre-set as a default language.

Each language can be assigned a fallback language. If you set up a fallback language and try to retrieve content in a language it is not translated into, the content will come back in the fallback language instead.

Every website channel has a primary language (typically assigned at the time of channel creation). This is a “default” language for the channel. When a visitor navigates to your website without specifying the language code in the URL (e.g., baseURL/page), they will see the page content in the primary language. Navigating to baseURL/<language_code_name>/page will return the page content in a specific language. We talk more about multilingual URLs in the next part of this mini-series.

Multilingual in multichannel setup

Languages are global and exist above website channels. All website channels are automatically available in all defined languages. At this time, there is no way (out of the box) to configure a channel to be available only in a subset of languages.

This means that you can get in a situation where one is able to retrieve your website pages in a language they are not (and are not meant to be) translated into.

For example, you have three languages defined in your solution: English, Spanish (with a fallback to English), and French (with a fallback to English). Your instance of Xperience contains two website channels, each translated into two language versions:

  1. Channel A in English and Spanish
  2. Channel B in English and French

Even though by design, pages of Channel A are not supposed to be available in French, when you request https://channelA/fr, the system will still return 200 OK because French exists globally (content will come back in the fallback language, English).

This is a behavior to be mindful of when you work with multichannel and multilingual solutions. The best way of handling it will depend on your implementation, need and preference and is out of the scope of this guide. 

Editor’s task (optional): Add Spanish language with a fallback to English

Log into the administration interface to experience the theory in practice. If you have been working off the main branch of our Training guides repository, the only language in your Xperience instance is English at the moment.

  1. Follow the documentation to create a new language. Call it Español, with language code es, do NOT and set the fallback language yet.
  2. Try to navigate to different pages of your website, adding the code /es to the base URL (e.g., http://localhost:53415/es or http://localhost:53415/es/cookie-policy). The system will return a 404 Not Found error each time because there is no Spanish version of your content to display.
  3. Now, go back to Languages in the administration interface and set the fallback language to English. Notice that you can now see your pages, and the content comes back in the primary language - English.