See adding languages.
See routing locales.
The application uses Symfony Translation to manage translated messages on the page (e.g. microcopy such as 'Displaying 100 results').
Translations are stored in translations/
and use the ICU message format.
It's important for messages to have clear and understandable keywords that represent what the message is for. We can also use nested groups to help indicate where the content is used.
E.g.
footer.copyright_message: Copyright © 2020 W3C <sup>®</sup>
See https://symfony.com/doc/current/translation.html#using-real-or-keyword-messages
Output message via the trans filter:
{ 'title'|trans }}
You can pass arguments to the translation via:
<p>{{ 'api_available.w3c'|trans({'available': w3c_available}) }}</p>
Read more on selecting different messages based on a condition.
w3c/website-templates-bundle also defines and uses some translatable
strings for messages that are common to all templates. They are defined in a different translation domain named
w3c_website_templates_bundle
as recommended
in Symfony best practices.
Those strings are defined in the bundle's translations directory.
To use those strings you need to pass the domain as a parameter of the trans filter or tag:
{{ 'w3c.description'|trans([], 'w3c_website_templates_bundle') }}
There is a need to display localized messages on the front-end via JavaScript. The translation of these messages is managed in the template bundle. Please refer to the documentation on internationalization of the W3C template bundle.