What's on this page
Localization
Cecil support text translation and date localization.
Text translation
Uses the trans tag or filter to translate texts in templates.
{% trans with variables into locale %}{% endtrans %} {{ message|trans(variables = []) }} Examples
{% trans %}Hello World!{% endtrans %} {{ message|trans }} Include variables:
{% trans with {'%name%': 'Arnaud'} %}Hello %name%!{% endtrans %} {{ message|trans({'%name%': 'Arnaud'}) }} Force locale:
{% trans into 'fr_FR' %}Hello World!{% endtrans %} Pluralize:
{% trans with {'%count%': 42}%}{0}I don't have apples|{1}I have one apple|]1,Inf[I have %count% apples{% endtrans %} Translation files
Translation files must be named messages.<locale>.<extension> and stored in the translations directory.
Supported file extensions are defined by each translation format in layouts.translations.formats.
The locale code (e.g.: fr_FR) of a language is defined in the languages entries of the configuration.
Example:
<mywebsite>
└─ translations
├─ messages.fr_FR.mo <- Machine Object format
└─ messages.fr_FR.yaml <- Yaml format Date localization
Uses the Twig format_date filter to localize a date in templates.
{{ page.date|format_date('long') }}
{# September 30, 2022 #} Supported values are: short, medium, long, and full.