Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8961959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:00:58+00:00 2026-06-15T16:00:58+00:00

I use twig for templating in a multilingual Symfony2 project. There is a language

  • 0

I use twig for templating in a multilingual Symfony2 project. There is a language switcher in layout.html.twig

I want the user can switch languages without changing the current page by clicking the language link. I have written the following code which just does duty for static pages. Since the language links just pass locale to the route, in case of involvement of additional required parameters, it obviously throws the exception: route has some missing mandatory parameters

<ul id="lang">
    <li><a href="{{ path(app.request.attributes.get('_route'), {_locale: 'az'}) }}">AZ</a></li>
    <li><a href="{{ path(app.request.attributes.get('_route'), {_locale: 'en'}) }}">EN</a></li>
</ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:00:59+00:00Added an answer on June 15, 2026 at 4:00 pm

    You can get the route parameters with .get('_route_params') and merge them with your desired locale:

    <ul class="lang-menu">
      <li><a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale': 'ca'})) }}">Català</a></li>
      <li><a href="{{  path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale': 'en'}))}}">English</a></li>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use Symfony2 and twig templating. Think of the Q&A exact same as stackoverflow.
Using symfony2 with twig templates, I normally use js embedded inside the *html.twig file
Is it possible to use Twig in Silex from Symfony2 project instead from the
I am trying to use teh Twig i18n Extension. As far as I can
i'm having a problem when i want to use split function in Twig, i
In Symfony 2 templates (using Twig), how can I effectively check whether a user
There is something I do not understand with locale management in Symfony2. I want
Is there a good way to indicate incorrect use of Twig macro from inside
I am using Twig and this date filter http://www.twig-project.org/doc/templates.html#date Apparently they are looking out
Templating not found form_div_layout.html.twig Path in twig loader: Array ( [0] => /var/www/nrp.new-generation.com.ua/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views )

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.