Custom language variables
When working with multi-language site projects, you often run into the problem of needing language-specific variables/strings. Simple things like translated button labels for your contact form for example or other translatable parts, which don't need to be administrated by editors.
For such a case, Kirby has a built-in language variable management.
Add the folder
/site/languages and insert a PHP file with the specific language shortcode for each available language:
/site/languages/en.php /site/languages/de.php /site/languages/fr.php
Those files can contain as many custom variables as you need.
<?php l::set('submit', 'Submit'); l::set('cancel', 'Cancel');
<?php l::set('submit', 'Abschicken'); l::set('cancel', 'Abbrechen');
l::set also accepts an associative array:
<?php l::set(array( 'submit' => 'Submit', 'cancel' => 'Cancel', 'next' => 'next', 'previous' => 'previous', ));
Those translated variables can be used in any template, plugin or snippet:
<input type="submit" value="<?php echo l::get('submit') ?>" />