Since Version 1.1 Kirby has full built-in multi-language support. You are able to translate each and every part of your website with a few simple steps.
Jump to your config file site/config/config.php
and activate multi-language support there:
c::set('lang.support', true);
c::set('lang.default', 'en');
c::set('lang.available', array('en', 'de'));
c::set('lang.detect', true);
If you are still using an older version of Kirby, please upgrade and add those lines to your existing config file.
As soon as you activate multi-language support, Kirby will automatically create new language-specific URLs for your site:
You can define any number of available languages by adding their 2-character shortcodes to the lang.available
array:
c::set('lang.available', array('en', 'fr', 'it', 'de'));
To make sure that you provide a proper fallback for parts of your site, which are not translated yet, you must define a default language. Kirby will automatically take care of replacing untranslated content from other languages with content from your default language, so you will never get empty or broken spaces on your site.
c::set('lang.default', 'en');
If you set lang.detect
to true, Kirby will automatically try to find the best language for your visitor and will redirect them to the translated version. This is activated by default, but you can switch it off, so visitors will always land on your default translation first.
c::set('lang.detect', true);
Adding translated content couldn't be easier. Just add another text file to your content folder and append the language shortcode:
Make sure you always got a text file for your default language. Otherwise Kirby won't 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. 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.
To provide translations for your global site info, add language-specific site.txt to your main content folder files like this: