Go to page content

Translations

Zotonic is completely multilingual out of the box.

Why

Many sites need to support content and templates in multiple languages. This article describes how translations are handled.

Assumptions

You have mod_translation enabled.

How

Before you can use multiple languages you need to tell Zotonic which languages you are going to use.  You can do this in the /admin, following the Translation menu item on the left.

There you can add languages, enabled/disable languages and more. Note that a language is always a two letter ISO639-1 language code. In the future we might add language variations like en-us or nl-be.

Translation page

Translations

For translations you need to discern between two types of translations:

  1. Fixed texts in your templates
  2. Your content, as edited in the admin

The fixed texts are translated using GNU gettext po files and tools. A good po file editor can be found at: http://www.poedit.net/

.po and .pot files

In the translation directory of the modules you can find the .po files containing the translations. They are marked with the two letter language code.  Optionally you can name your file like: nl.foobar.po as Zotonic will only look at the part till the first '.' for the language code.

The basis for these files is the .pot file which is located in the template subdirectory of the translations directory. This .pot file is generated when you click on the generate .pot files button on the Translation page in the admin.

After clicking generate .pot files Zotonic will parse all your templates and erlang code for translatable strings. These strings are then added to the .pot file.

Note that we assume that all your translatable strings are written in English (en).

Translating content

When you have enabled languages on the Translation page of the admin you will see a Translations item on the right of the edit page.

Language selection

Every language has a checkbox. When you click a checkbox the language will become visible as a tab on your content items.

Language tabs

Pages in Zotonic are translated on a per-page basis. So you can start translating your site by translating the most important pages first. Zotonic will try to serve the page in the language of the user or the selected language from the URL. If that fails Zotonic will fall back on the default language as configured on the Translation admin page.

Troubleshooting

No trouble shooting known yet.

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.