Open simohammedhttp opened 10 years ago
We're seeing this too.
We're having the same problem. Is there an solution?
Since we're all developers here somebody might as well go and looking into final routes built by the library to discover the problem 😉 . No real need to wait for 3 years to create a solution.
Hi all! Happy to review any PRs, it shouldn't be too difficult to solve
While looking at the library I've found out, that it takes all your routes prior to their dumping in compiled router and modifies them according to the strategy. This info should help to anyone looking at solving this problem.
I solved this a long time ago with a workaround, I mean the issue must be fixed at the bundle level for a reliable/sustainable solution.
I tweaked the @route.
@Route("{_locale}{articlePath}", requirements={"_locale"="en|ar|", "articlePath"=".+"})
.. time flies ... 3 years :o
@simohammedhttp Yeah, that's basically not the fix I guess. Looking in to the library right now to fix it, but I don't know exactly where to look. Any hints? Probably somewhere in the code the $request->setLocale()
must requested right?
Unfortunately, I dont't have any hint.
If the requirements={"articlePath"=".+"}
part of annotation is removed, then it works?
@aik099 That doesn't solve the issue when requesting the locale from $request->getLocale()
. I'm trying to solve this issue, kind of new go Symfony bundles, hadn't found an fix for it @aik099. Where do we need to fix this issue?
@aik099
I just checked the code source of the solution I have implemented :
jms_i18n_routing:
default_locale: fr
locales: [fr, ar, en]
strategy: prefix_except_default
I used this route:
* @Route("{_locale}{articlePath}", requirements={"_locale"="en|ar|", "articlePath"=".+"})
* @Template()
The default 'fr' locale is made optional "en|ar|", look at the last vertical bar.
Now the following pages work great for both locales:
https://www.afa-advisory.com/conseil/développement-web-et-mobile (without fr, otherwise route won't be matched) https://www.afa-advisory.com/en/consulting/mobile-and-web-development
Hi,
The JMSI18nRoutingBundle works perfectly for the majority of my routes.
jms_i18n_routing: default_locale: fr locales: [fr, ar, en] strategy: prefix_except_default
But I had some issues with this route:
@Route("/{articlePath}", requirements={"articlePath"=".+"}) showAction($articlePath, Request $request)
@Route Is intended to match routes like category/subCategory/../articleSlug
$request->getLocale() always returns fr, inside the controller for these URLs:
/en/.. /ar/.. /fr/.. /.. (fr omitted)
And the route /fr/.. must not be matched according to the intended behaviour with the prefix_except_default strategy.
tks,