Skip to content

Multilingual Websites with MODX and Babel

Multilingual Websites with MODx and Babel

This is old!

This tutorial is a slightly modernized version of the old blog entry on multilingual-modx.com which is available only in the WaybackMachine. It uses a routing plugin for easier maintaining the contexts. The links in the text are updated to actual or to WaybackMachine versions.

In the official documentation of the Babel Extra I’ve only provided a short summary of how to set up your MODx contexts for a multilingual website and referred to an outdated tutorial. Many Babel users contacted me or posted an issue on GitHub because they had some troubles with Babel. Most of these troubles were not related to Babel itself but have been caused by setting up the contexts incorrectly. With this small tutorial I want to support you in configuring your multilingual websites with MODx and Babel.

Important

I've described a more SEO-friendly approach in a new article which you may want to read, too.

First of all I want to thank digital butter for their great tutorial which explains how to set up a multilingual website with MODx. I referred to their tutorial in the official documentation. However, since there have been made some changes to the access control system of MODx you have to apply some more steps to set up your multilingual website correctly.

In this article I’ll simply list all the steps necessary to set up your multilingual site in a very basic way. I won’t provide as many details as the guys from digital butter did. There are already some helpful resources available on the web where you can obtain additional information:

Step-by-Step Instructions

Ok. If you have worked through the documents listed above and installed a new clean MODx environment you should be ready to set up your multilingual website.

I’ll go through all the necessary steps by configuring an example website which will be available in three languages: English, German and French. The English site will be available via www.​example.com the German site via www.​example.de and the French one via www.​example.fr.

  1. Create your contexts for each language:
    The default web context will be used for the English site, a de context for the German and a fr context for the French site:

    Create a context for each language

  2. Configure language specific settings of all your contexts: site_url and cultureKey.

  3. web context: site_url: https://​www.​example.com, cultureKey: en
  4. de context: site_url: https://​www.​example.de, cultureKey: de
  5. fr context: site_url: https://​www.​example.fr, cultureKey: fr

    Create language specific settings for each context

  6. Grant the "Load Only" access policy for all your contexts to the anonymous group to let your users load the contexts.

    Grant access to contexts

  7. Install a routing extra from the MODX repository, i.e. SmartRouting, xRouting or LangRouter via the MODX package management

  8. Install the Babel Extra via package management.

Now you should be able to create documents and link translations via Babel in your MODx manager. For information about how to use the MODx lexicon feauture you may take a look at the tutorial at digital butter or official documentation.

Common Mistakes

In order to avoid mistakes during setting up your contexts here are some common mistakes which have been made by users who requested my help:

  • Babel does not display the correct language of a context
    You may have forgotten to configure the cultureKey setting in the specific context. Babel uses this setting to determine the language of a context.

  • Babel does not display all links to translated documents in the front-end
    You may have forgotten to grant the "Load Only" access policy for your visitors to the specific contexts. Or you may have forgotten to flush the permissions.

  • The site is always displayed in the same language Check your routing plugin and make sure it works properly.

Further Help

Important

I've described a more SEO-friendly approach in a new article which you may want to read, too.

If you’re still having problem regarding your multilingual site and Babel have a look at the closed issues on GitHub. If you can’t find a solution there, feel free to post a new issue. We try to help you and incorporate your feedback to improve Babel.