Search code examples
symfonyfosuserbundlesonata-user-bundle

FOSUserBundle Translate route name


Hi I'm using routes of the FOSUserBundle with SonataUserBundle. Which are in english. I would like to translate them in French.

I did it the routing.yml

sonata_user_resetting:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_resetting_1.xml"
    prefix: /reset

sonata_user_profile:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_profile_1.xml"
    prefix: /mon-compte

sonata_user_register:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_registration_1.xml"
    prefix: /inscription

sonata_user_change_password:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_change_password_1.xml"
    prefix: /mon-compte

sonata_user:
    resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
    prefix: /admin

sonata_user_admin_security:
    resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
    prefix: /admin

sonata_user_admin_resetting:
    resource: '@SonataUserBundle/Resources/config/routing/sonata_resetting_1.xml' # et non 'admin_resetting.xml' : erreur dans la doc
    prefix: /admin/reset

But I don't see where I can configure the /login route.

You have an idea?

EDIT:

My AppKernel.php

$bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new FM\AppBundle\AppBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            // These are the other bundles the SonataAdminBundle relies on
            new Sonata\CoreBundle\SonataCoreBundle(),
            new Sonata\BlockBundle\SonataBlockBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            // Storage and SonataAdminBundle
            new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
            new Sonata\AdminBundle\SonataAdminBundle(),
            new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
            new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'),
            new Application\Sonata\UserBundle\ApplicationSonataUserBundle(),
        );

The Application\Sonata\UserBundle\ApplicationSonataUserBundle is the the Bundle hosting my User Entity.


Solution

  • Login route is defined in FOS/UserBundle/Resources/config/routing/security.xml.

    Example code change:

    fos_user_security_login:
        path:      /yourpath/login
        defaults:  { _controller: FOSUserBundle:Security:login, _method: POST }
    

    Read more about overriding FOSUserBundle routes here: http://symfony.com/doc/current/bundles/FOSUserBundle/routing.html