src/Storefront/Resources/views/storefront/layout/header/actions/language-widget.html.twig line 1

  1. {% block layout_header_actions_language_widget%}
  2.     {% if position is empty %}
  3.         {% set position = 'top-bar' %}
  4.     {% endif %}
  5.     {% if  page.header.languages.count > 1 %}
  6.         <div class="top-bar-nav-item top-bar-language">
  7.             {% block layout_header_actions_language_widget_form %}
  8.                 <form method="post"
  9.                       action="{{ path('frontend.checkout.switch-language') }}"
  10.                       class="language-form"
  11.                       data-form-auto-submit="true">
  12.                     {% block layout_header_actions_language_widget_content %}
  13.                         {% set isoCode = page.header.activeLanguage.translationCode.code|lower|split('-') %}
  14.                         {% set language = isoCode[0] %}
  15.                         {% set country = isoCode[1] %}
  16.                         <div class="languages-menu dropdown">
  17.                             <button class="btn dropdown-toggle top-bar-nav-btn"
  18.                                     type="button"
  19.                                     id="languagesDropdown-{{ position }}"
  20.                                     data-bs-toggle="dropdown"
  21.                                     aria-haspopup="true"
  22.                                     aria-expanded="false">
  23.                                 <div class="top-bar-list-icon language-flag country-{{ country }} language-{{ language }}"></div>
  24.                                 <span class="top-bar-nav-text">{{ page.header.activeLanguage.name }}</span>
  25.                             </button>
  26.                             {% block layout_header_actions_languages_widget_form_items %}
  27.                                 <div class="top-bar-list dropdown-menu dropdown-menu-right"
  28.                                     aria-labelledby="languagesDropdown-{{ position }}">
  29.                                     {% for language in  page.header.languages %}
  30.                                         <div class="top-bar-list-item dropdown-item{% if language.id is same as(page.header.activeLanguage.id) %} item-checked{% endif %}"
  31.                                              title="{{ language.translated.name }}">
  32.                                             {% block layout_header_actions_languages_widget_form_items_flag %}
  33.                                                 {% set isoCode = language.translationCode.code|lower|split('-') %}
  34.                                                 {% set flagLanguage = isoCode[0] %}
  35.                                                 {% set flagCountry = isoCode[1] %}
  36.                                                 <label class="top-bar-list-label"
  37.                                                        for="{{ position }}-{{ language.id }}">
  38.                                                     <input id="{{ position }}-{{ language.id }}"
  39.                                                            class="top-bar-list-radio"
  40.                                                            value="{{ language.id }}"
  41.                                                            name="languageId"
  42.                                                            type="radio"
  43.                                                         {% if language.id is same as(page.header.activeLanguage.id) %} checked{% endif %}>
  44.                                                     <div class="top-bar-list-icon language-flag country-{{ flagCountry }} language-{{ flagLanguage }}"></div>
  45.                                                     {{ language.name }}
  46.                                                 </label>
  47.                                             {% endblock %}
  48.                                         </div>
  49.                                     {% endfor %}
  50.                                 </div>
  51.                             {% endblock %}
  52.                         </div>
  53.                         <input name="redirectTo" type="hidden" value="{{ app.request.get('_route') }}"/>
  54.                         {% for key, value in app.request.attributes.get('_route_params') %}
  55.                             <input name="redirectParameters[{{ key }}]" type="hidden" value="{{ value }}">
  56.                         {% endfor %}
  57.                     {% endblock %}
  58.                 </form>
  59.             {% endblock %}
  60.         </div>
  61.     {% endif %}
  62. {% endblock %}