2
votes

I have a website developed using Symfony 2.8 and Sonata Admin.
The frontend website is entirely in French and so are all the database entities (translated using Gedmo Translatable).

Unfortunately I can't set the global default language to 'fr' because I want the admin area to be in English:

parameters:
    locale: fr

framework:
    #esi: ~
    translator: { fallbacks: ['%locale%'] }
    default_locale: '%locale%'

stof_doctrine_extensions:
    default_locale: '%locale%'
    orm:
        default:
            timestampable: true
            blameable: true
            translatable: true

sonata_translation:
    locales: ['%locale%']
    default_locale: '%locale%'
    gedmo:
        enabled: true

If I change the global language to 'fr' all the labels become French (Déconnexion, Éditer etc...).

How can I have all the website and the entities in French but the admin interface in English?

1

1 Answers

1
votes

You can override the locale for an area of the site with a onKernelRequest event listener, as detailed in 'How to Work with the User's Locale'. Here, you would watch for a URL that was within the admin-area, and change the locale to 'en_GB', etc, in the Request object.