Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Latest commit

 

History

History
17 lines (15 loc) · 502 Bytes

File metadata and controls

17 lines (15 loc) · 502 Bytes

Language switch

You can create a language switch using this code

{% if app.request.attributes.has('_route_params') %}
  <ul class="language-select nav navbar-nav">
    {% for locale in locales %}
     <li {% if locale == app.request.locale %}class="active"{% endif %}>
       <a href="{{ path(app.request.attributes.get("_route"), app.request.attributes.get('_route_params')|merge({"_locale": locale})) }}">
         {{ locale }}
       </a>
     </li>
    {% endfor %}
  </ul>
{% endif %}