0

How are you doing? I'm developing a multilingual platform with Symfony2. If someone types in www.url.com/project I want to have it redirected to www.url.com/en/project. Whats the easiest way to do so without repeating a method and all the routes a couple of times?

For the main url www.url.com to www.url.com/en/ I use the following controller

    public function rootAction(Request $request) {
    $locale = $request -> getLocale();
    return $this -> redirect($this -> generateUrl('dbe_underConstructionLang', array('_locale' => $locale)));
    }

And here the routes: The default:

dbe_underConstruction:
    path:     /
    defaults: { _controller: DbeBundle:UnderConstruction:root }

This is a default page

dbe_aboutus:
    path:     /{_locale}/aboutus
    defaults: { _controller: DbeBundleBundle:Aboutus:index }
    requirements:
        _locale: en|fr|de

Furthermore I was not able to make the login route multilingual because in the security.yml I was not able to set the required _locale parameter:

dbe_login:
path:     /login
defaults: { _controller: DbeBundle:Login:login}

 firewalls:
    secured_area:
        pattern:    ^/
        form_login:
            check_path: /login_check
            login_path: /login
        logout:
            path:   /logout
            target: /

Thanks already!

joelschmid
  • 828
  • 1
  • 16
  • 32
  • check [this](http://stackoverflow.com/questions/7903477/symfony2-default-locale-in-routing),hope you can find some solutions.. – Leo Silence Mar 26 '14 at 10:00

1 Answers1

1

For me, best solution is to use JMSI18RoutingBundle. There are some configurations in config.yml and nothing else - no changes in routing.yml.

repincln
  • 2,029
  • 5
  • 24
  • 34