5. Global locale switcher

SonataTranslationBundle also provides a nice global locale switcher for your admin.

5.1. Prerequisites

Install the following Sonata dependencies:

5.2. Configuration

Override the standard layout template with the one from the bundle:

1
2
3
4
5
# config/packages/sonata_admin.yaml

sonata_admin:
    templates:
        layout: '@SonataTranslation/standard_layout.html.twig'

Configure route:

1
2
3
4
# config/routes.yaml

sonata_translation:
    resource: '@SonataTranslationBundle/Resources/config/routes.yaml'

Enable locale_switcher:

1
2
3
4
# config/packages/sonata_translation.yaml

sonata_translation:
    locale_switcher: true

5.3. How it looks

You are done and you probably want to know how this looks like in the admin interface. Well, let’s find out by going to /admin

Sonata Dashboard with locale switcher