schmittjoh / JMSI18nRoutingBundle

Allows you to internationalize your routing
http://jmsyst.com/bundles/JMSI18nRoutingBundle
358 stars 159 forks source link

Multiple routes ignore requirements #192

Closed martijnhartlief closed 8 years ago

martijnhartlief commented 8 years ago

With the following Route annotation:

/**
 * @Route("/{name}-example", requirements={"_locale" = "en"})
 * @Route("/{name}-voorbeeld", requirements={"_locale" = "nl"})
 */

If i generate the url with {{ path('app_controller_action', {'name': 'test', '_locale': 'nl'}) }} It generates this url: /nl/test-example when I would expect it to generate /nl/test-voorbeeld

Also the route works with the wrong suffix when I would expect it to return a 404 exception.

When I reverse the Route annotation order it generates it correctly, but It doesn't work for 'en'. So I have the feeling it completely ignores the requirements.

How can I force this behaviour?

stof commented 8 years ago

Symfony does not support locale requirements (unless the _locale placeholder exists in the URL)

martijnhartlief commented 8 years ago

Even if I add the _locale in the url, it will fail after trying to matching the first route. I guess it's not possible what i want.

schmittjoh commented 8 years ago

Why do you need this bundle if you enumerate all routes on the controller?

martijnhartlief commented 8 years ago

To clean up the locales from the routing.

Not all routes work have to be like this, but for SEO reasons the customer wants to prefix / suffix certain keywords based on locale. I was hoping this bundle would return the correct route based on the supplied/active locale.

But as @stof mentioned, it has probably more to do with how Symfony handles requirements than an actual defect of this bundle :)

I also found out you can't mix prefix locale and domain based locale selection, so I'll have to write something custom anyway.