1
votes

I want to build a multilingual app with sf2. I want multiple routes to point to the same controller and when i generate urls i want them generated correctly, even if there are multiple routes that point to that controller.

My research has shown that i can use the @Route annotation to add multiple routes to a controller but how will i generate the correct url then ?

Ideally i would like to be able to define a route like so :

homepage:
    pattern:
       en:    /homepage
       fr:    /le_homepage
    defaults:  { _controller: AcmeDemoBundle:Main:homepage }

And the route should be able to identify the pattern and determine the culture for which it has been matched. Also when i generate an url it should let me provide a culture or get the default culture and use the appropriate pattern in order to generate the url. For example if i generate the homepage url while the user is in the fr language it should go to /le_homepage. If in en language it should go to /homepage.

Now clearly this is not available in sf2. Does anyone have a solution for this ? I thought about manually adding homepage_en: and homepage_fr: routes but then i would constantly have to duplicate stuff and be careful when generating the urls. If anyone has a better solution i'd like to hear it. Thanks.

1

1 Answers

1
votes