Skip to content

Kirby 3.9.8

Translating your content

Non-Panel users

Translating your pages

Translating the content of your pages is just a matter of adding a text file for every language:

  • content
    • home
      • home.en.txt
      • home.de.txt
      • home.fr.txt

The added language code must match the code in your languages setup.

Make sure you always have a text file for your default language. Otherwise Kirby will not be able to provide a fallback for missing translations.

In your content files you can use the same fields and just fill in the translated text. The best way to proceed at the beginning is to start with the default language and when you are happy with the results, duplicate the default language files, rename them and translate them.

If you use the Panel, you don't have to worry about adding additional translation files. The Panel will handle that for you.

Translating your site.txt

The global information about your site can be translated in the same way by adding a site.txt for every language:

  • content
    • site.de.txt
    • site.en.txt
    • site.fr.txt

Translating file meta information

You can add meta information for each file in your content folders by adding a new text file for it. For example, to add meta info for an image called myimage.jpg, you would add a new text file called myimage.jpg.txt. To translate those meta info files, you have to append the language code again:

  • myimage.jpg
  • myimage.jpg.en.txt
  • myimage.jpg.de.txt
  • myimage.jpg.fr.txt

Panel users

If you only work in the Panel, you don't have to worry about adding language extensions to content files. The Panel handles this automatically.

To translate a page in the Panel, switch from the default language to the target language using the language selector.

By default, the original content of the default language is shown to facilitate translations.

Preventing translations of individual fields

There are often situations where translations of a field don't make sense. In such cases, you can prevent translations via a blueprint option:

fields:
  headline:
    type: text
  year:
    type: number
    translate: false

This will make the field readonly in all but the default languages.

Creating new pages

When you create pages via the Panel, a new page is always created in the default language first, even if you add the page while a secondary language is active. This is done because the default language is required.

It is therefore highly recommended to enter the Title and Url appendix in the default language when creating a new page to make sure that the URL for the default language is correct and to avoid having to change it later.

Being more productive

Check out the following cookbook recipe to learn how you can export and import translations for external translators: