3

I have a project multi language with a <select> in all footer pages. When I'm in pages from my web, the url is like this: /es/privacy /en/privacy. Now I want delete the language in specific language, english.

if I'm in privacy page browsing in Spanish /es/privacy but if I'm browsing in English /privacy. This is an example of my routing.yml:

privacy_lang:
 path: /{_locale}/privacy
 defaults: { _controller: AppBundle:Documents:privacy }

privacy:
 path: /privacy
 defaults: { _controller: AppBundle:Documents:privacy }

And this my controller:

    /**
 * @Route("/privacy", name="privacy")
 * @Method("GET")
 */
public function privacyAction(Request $request)
{
    return $this->render('default/privacy.html.twig', [
        'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
    ]);
}

Now I have button in my page goes to Privacy Page:

<a class="privacy enllac-lower" href="{{ path('privacy_lang') }}">Privacy Policy</a>

How can I delete /en/ when user are browsing in english? Now if I go to http://www.myweb.com/privacy redirects to http://www.myweb.com/es/privacy.

ximo12
  • 147
  • 2
  • 9
  • Is using URL rewriting for all URL's with en an option for you ? I mean you'll keep all the logic of your website and multilang intouched, and just add a rule to rewrite `site.ext/en/page` to `site.ext/page` – teeyo Oct 05 '17 at 15:05
  • Or take a look at this answer : https://stackoverflow.com/questions/7903477/symfony2-default-locale-in-routing – teeyo Oct 05 '17 at 15:07

0 Answers0