templates/vitrine/lexend/articles/components/languages.html.twig line 1

Open in your IDE?
  1. {% set nameR = app.request.attributes.get('_route') %}
  2. {% set nameR = nameR | replace({'locale_': ''}) %}
  3. {% set available_locales = app_locales|split('|') %}
  4. <li class="d-inline-block">
  5.     <a href="#" class="hstack gap-1 text-none fw-medium" role="button" aria-haspopup="true" aria-expanded="false">
  6.         <i class="icon icon-1 unicon-wikis"></i>
  7.         <span>{{ language_names[app.request.locale] | default(app.request.locale|upper) }}</span>
  8.     </a>
  9.     <div class="w-200px py-1 bg-white dark:bg-gray-700 shadow-xs rounded-2" data-uc-drop="mode: click; offset: 0; pos: top-right; boundary: !.uc-navbar-container; animation: uc-animation-slide-top-small; duration: 150;">
  10.         <ul class="nav-y gap-0 fs-7">
  11.             {% for locale in available_locales %}
  12.                 <li>
  13.                     {% if locale == app.request.locale %}
  14.                         {# Langue actuelle - non cliquable #}
  15.                         <span class="w-100 p-1 px-2 hover:bg-gray-600 hover:bg-opacity-5 dark:hover:bg-white duration-150">
  16.                             <img class="w-20px rounded-1 me-1 rtl:me-0 rtl:ms-1" src="/assets/lexend/images/common/{{ locale }}.svg" alt="{{ language_names[locale] }}" />
  17.                             {{ language_names[locale] | default(locale|upper) }}
  18.                         </span>
  19.                     {% else %}
  20.                         {% if locale == 'en' %}
  21.                             {# Pour l'anglais, utiliser votre logique #}
  22.                             {% set articleLocale = getPathArticleLocale(locale,article.identifiant) %}
  23.                             {% if articleLocale %}
  24.                                 {% set urlArticle = '/' ~ path('blog_article',{'slug': articleLocale.slug})  %}
  25.                                 {% if articleLocale.pageslug3 is not empty %}
  26.                                     {% set urlArticle = '/'  ~ articleLocale.pageslug ~ '/' ~  articleLocale.pageslug2 ~ '/' ~ articleLocale.pageslug3  %}
  27.                                 {% elseif article.pageslug2 is not empty %}
  28.                                     {% set urlArticle =  '/'  ~ articleLocale.pageslug ~ '/' ~  articleLocale.pageslug2  %}
  29.                                 {% elseif article.pageslug is not empty %}
  30.                                     {% set urlArticle =  '/'  ~ articleLocale.pageslug  %}
  31.                                 {% endif %}
  32.                                 <a href="{{ urlArticle }}"
  33.                                    class="w-100 p-1 px-2 hover:bg-gray-600 hover:bg-opacity-5 dark:hover:bg-white duration-150"
  34.                                    hreflang="{{ locale }}">
  35.                                     <img class="w-20px rounded-1 me-1 rtl:me-0 rtl:ms-1" src="/assets/lexend/images/common/{{ locale }}.svg" alt="{{ language_names[locale] }}" />
  36.                                     {{ language_names[locale] }}
  37.                                 </a>
  38.                             {% else %}
  39.                                 {# Pas d'article dans cette langue - span sans lien #}
  40.                                 <span class="w-100 p-1 px-2 text-gray-400 dark:text-gray-500 cursor-not-allowed">
  41.                                     <img class="w-20px rounded-1 me-1 rtl:me-0 rtl:ms-1 opacity-50" src="/assets/lexend/images/common/{{ locale }}.svg" alt="{{ language_names[locale] }}" />
  42.                                     {{ language_names[locale] }}
  43.                                 </span>
  44.                             {% endif %}
  45.                         {% else %}
  46.                             {# Pour les autres langues, utiliser votre logique #}
  47.                             {% set articleLocale = getPathArticleLocale(locale,article.identifiant) %}
  48.                             {% if articleLocale %}
  49.                                 {% set urlArticle = '/' ~ locale ~ path('blog_article',{'slug': articleLocale.slug})  %}
  50.                                 {% if articleLocale.pageslug3 is not empty %}
  51.                                     {% set urlArticle = '/' ~ locale ~ '/' ~ articleLocale.pageslug ~ '/' ~  articleLocale.pageslug2 ~ '/' ~ articleLocale.pageslug3  %}
  52.                                 {% elseif article.pageslug2 is not empty %}
  53.                                     {% set urlArticle =  '/' ~ locale ~ '/' ~ articleLocale.pageslug ~ '/' ~  articleLocale.pageslug2  %}
  54.                                 {% elseif article.pageslug is not empty %}
  55.                                     {% set urlArticle =  '/' ~ locale ~ '/' ~ articleLocale.pageslug  %}
  56.                                 {% endif %}
  57.                                 <a href="{{ urlArticle }}"
  58.                                    class="w-100 p-1 px-2 hover:bg-gray-600 hover:bg-opacity-5 dark:hover:bg-white duration-150"
  59.                                    hreflang="{{ locale }}">
  60.                                     <img class="w-20px rounded-1 me-1 rtl:me-0 rtl:ms-1" src="/assets/lexend/images/common/{{ locale }}.svg" alt="{{ language_names[locale] }}" />
  61.                                     {{ language_names[locale] }}
  62.                                 </a>
  63.                             {% else %}
  64.                                 {# Pas d'article dans cette langue - span sans lien #}
  65.                                 <span class="w-100 p-1 px-2 text-gray-400 dark:text-gray-500 cursor-not-allowed">
  66.                                     <img class="w-20px rounded-1 me-1 rtl:me-0 rtl:ms-1 opacity-50" src="/assets/lexend/images/common/{{ locale }}.svg" alt="{{ language_names[locale] }}" />
  67.                                     {{ language_names[locale] }}
  68.                                 </span>
  69.                             {% endif %}
  70.                         {% endif %}
  71.                     {% endif %}
  72.                 </li>
  73.             {% endfor %}
  74.         </ul>
  75.     </div>
  76. </li>