Setting Up Translations
Creating custom translations is only available manually through files.
Flute CMS supports translations into any languages.
Creating Custom Translations
All translations are located in the i18n
folder, inside which language directories are placed.
To create your own translation (for example, for use in navigation), follow these steps:
- Go to the
i18n
folder in the project root. - Open the folder with the desired language (for example,
en
). - Create a new PHP file with an arbitrary name, for example
my_translation.php
. - Add translations in PHP array format.
Example structure and file /i18n/en/my_translation.php
:
- my_translation.php
- def.php
- admin.php
- auth.php
- ...
// /i18n/en/my_translation.php
return [
'my_key' => 'My translation',
];
Using Translations
To use the created translation, use the syntax filename.key
. In the example above, this would be:
my_translation.my_key
You can use translations in the following places:
- Menu items
- Social network names
- Site footer elements
- Page titles
- And any other interface elements
If there is no translation for the current language, the first found translation will be used (English by default).
If English is disabled, the key will be displayed instead of text.
Integrating Your Own Language
To integrate your own language that is not in Flute CMS, follow these steps:
Modify the config/lang.php
file and add your language to the available
and all
arrays.
<?php
return array (
'locale' => 'en',
'cache' => false,
'available' =>
array (
0 => 'en',
1 => 'ru',
2 => 'pl',
3 => 'uk',
4 => 'de',
5 => 'zh',
6 => 'fr',
7 => 'es',
8 => 'uz',
9 => 'pt',
10 => 'br',
// In our case this will be Italian
11 => 'it',
),
'all' =>
array (
0 => 'en',
1 => 'ru',
2 => 'pl',
3 => 'uk',
4 => 'de',
5 => 'zh',
6 => 'fr',
7 => 'es',
8 => 'uz',
9 => 'pt',
10 => 'br',
// Our language
11 => 'it',
),
);
After entering the language, create a folder with the language name in the i18n
folder and gradually add all translation files to it.
Example final structure in the i18n
folder:
- def.php
- admin.php
- auth.php
- ...