Skip to content

Multilanguage

Content language

The default language is English and it is set up in /site/languages/config.php.

c::set('languages', [
    [
        'code'    => 'en',
        'name'    => 'English',
        'default' => true,
        'locale'  => 'en_US',
        'url'     => '/',
    ],
]);

Change the default language

To change the default language, define the new values for language code, name and locale. For example, if your default language is German, your code will be like this:

c::set('languages', [
    [
        'code'    => 'de',
        'name'    => 'Deutsch',
        'default' => true,
        'locale'  => 'de_DE',
        'url'     => '/',
    ],
]);

Adding more languages

You can add more languages to your site in /site/languages/config.php:

c::set('languages', [
    [
        'code'    => 'en',
        'name'    => 'English',
        'default' => true,
        'locale'  => 'en_US',
        'url'     => '/',
    ],
    [
        'code'    => 'de',
        'name'    => 'Deutsch',
        'locale'  => 'de_DE',
        'url'     => '/de',
    ],
]);

If you define multiple languages, a language switch menu will appear in the header.

Switching from single language to multilanguage

If you already have content with a single language you can switch to multilanguage renaming your text files in the content folder to include the new language code.

i.e.
projects.txt > projects.en.txt
image.jpg.txt > image.jpg.en.txt

Note: This is a manual process, Kirby does not handle it automatically yet.


Panel language

The panel fields are translated into English, German and Spanish. To change the panel language go to Users, click on your username and select the language.

User language selection

Template language

Template strings like aria labels, screen reader texts, form fields, buttons, etc. are translated into English, German and Spanish.

If you need to add a new language go to site/languages and insert a new language file.

Language files

For more information about languages visit Kirby documentation.