Back to blog

Multicultural site with enduro.js

Wednesday, 25 January, 2017

Enduro.js provides multicultural pages out-of-the-box. Follow this short guide to learn how to set it up or check out the sample at https://github.com/Gottwik/enduro_samples/tree/master/multiculture

Setting up cultures

First you need to define a list of cultures your site will be in. There is a convenient command line shortcut to do this:

$ enduro addculture en de fr

This command tells enduro.js to generate separate pages for en, de and fr cultures.

Admin interface

Adding cultures also enables comfortable switching cultures in the admin interface.

Pro tip: You can use Cmd+1, Cmd+2, Cmd+3… to switch between cultures.

Routing

After adding cultures, your page will be accessible by adding the culture slug in front of the url, so the german version will be at www.yourdomain.com/de.

Notice that enduro.js will generate these culture-specific pages in addition to the default domain (first specified) for backward compatibility. In other words, www.yourdomain.com/blog will serve the same page as www.yourdomain.com/en/blog

Remove a culture

The cultures are stored in /cms/config/babel.js which look like this:

{
    cultures: [
        'en',
        'de',
        'fr'
    ]
}

You are free to modify this file to add, remove or edit cultures.

Like a boss

You can add culture_specific content by editing the content file directly with using Termination. Notice that the german content value just has $ in front(that’s the termination part) and _de at the end. Enduro.js parses this file and replaces greeting with greeting_de when generating the de culture.

{
    greeting: 'Hello',
    superlative: 'nice',
    $greeting_de: 'Guten tag',
    $greeting_fr: 'Bonne journée'
}
Back to blog

Shout out to pexels and freepik