Locale
The locale tag forces the content of a template in a certain language
When printed with print tags, the locale tag returns the chosen language of the current user.
{{ locale }}
Output
en
When using locale with logic tags, you can force the content to follow this language and ignore the chosen user language.
{% t="Hello" nl:"Hallo" fr:"Bonjour" %}
{% locale "nl" %}
{% t "Hello" %}
{% endlocale %}
Output
Hallo
Translations are the first thing that come to mind when using different languages, but currency formatting is also different across regions. Know that the locale tags will also influence any currency formatting used within them.
{% locale "nl" %}
{{ 6000000 | currency }}
{% endlocale %}
{% locale "en" %}
{{ 6000000 | currency }}
{% endlocale %}
Output
6.000.000,00
6,000,000.00
Currency format
You can also use Currencyconfiguration to customize the currency format, and you could do so within locale tags if you want to.
Updated over 1 year ago