Leafiny Documentation

Translation

This section describes Leafiny translation system.

Translation overview

Leafiny uses CSV to match English text with any language.

Current site language is defined in LANGUAGE configuration variable, set in vhost or .htaccess. See Create new Virtual Host section.

# .htaccess

SetEnv LANGUAGE en_US

Language notation separates each component of a locale with an underscore character:

<language code>_<country code>

Examples:

  • en_US English (United States)
  • en_GB English (United Kingdom)
  • fr_FR French (France)
  • fr_CA French (Canada)
  • de_DE Deutsch (Deutschland)
  • de_CH Deutsch (Schweiz)

CSV file

Local translate files are located in i18n directory of each modules. For Frontend module, this is modules/Frontend/i18n.

Add CSV file for the website language, example: modules/Frontend/i18n/fr_FR.csv.

CSV field options are:

  • Field delimiter: , (comma)
  • String delimiter: " (double quotation)

Character set is UTF-8

Open file and add English, French text translation:

"Hello World!","Bonjour le monde!"

Tamplate translation

In any template file, use translate filter to translate English text in website language:

{{ 'Hello World!'|translate }} <!-- Bonjour le monde! -->

Code translation

Everywhere in the code, use translate method from App static final class:

App::translate('Hello World!');

If no match is found the English text will be displayed.