Edit on GitHub
Jump to docs navigation

Twig Components / Language selector

Note: You are currently reading the documentation for Bolt 4.0. Looking for the documentation for Bolt 5.2 instead?

Use this to insert a toggle for the different languages defined in the site.

{% include 'helpers/_languageselect.html.twig' %}

Or, to output a <select> element, instead of an unordered list, use:

{% include 'helpers/_languageselect.html.twig' with {'type': 'select'} %}

All locales are available through the locales() helper twig functions, which returns a Collection. locales() returns all locales configured in the ContentTypes. Alternatively you can fetch all locales available in Bolt, using locales(all = true)

{{ dump(locales()) }}
{% set locales = locales() %}

The current locale is in the Request object, which is an instance of Symfony\Component\HttpFoundation\Request

{{ dump(app.request.getLocale()) }}


Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.