diff --git a/oe_whitelabel.theme b/oe_whitelabel.theme index 3aa615955637fe132d655830956608dc479fd97c..c21637cb2fd7d48a6fccba95aced63d76391e178 100644 --- a/oe_whitelabel.theme +++ b/oe_whitelabel.theme @@ -11,6 +11,8 @@ declare(strict_types = 1); * Implements hook__preprocess_links__language_block(). */ function oe_whitelabel_preprocess_links__language_block(&$variables) { + /** @var \Drupal\Core\Language\LanguageInterface[] $original_languages */ + $original_languages = \Drupal::service('language_manager')->getNativeLanguages(); $currentLanguage = \Drupal::languageManager()->getCurrentLanguage()->getName(); $variables['language']['link'] = [ 'label' => $currentLanguage, @@ -18,13 +20,21 @@ function oe_whitelabel_preprocess_links__language_block(&$variables) { 'target' => 'languageModal', ]; - foreach ($variables['links'] as $link => $values) { - if ($link !== $currentLanguage) { - $links[$link] = $values['link']['#title']; + $eu_links = []; + $non_eu_links = []; + foreach ($original_languages as $language) { + if ($language->getId() !== $currentLanguage) { + if ($language->getThirdPartySetting('oe_multilingual', 'category') === 'eu') { + $eu_links[$language->getId()] = $language->getName(); + } + else { + $non_eu_links[$language->getId()] = $language->getName(); + } + $links[$language->getId()] = $language->getName(); } } + unset($variables['links']); - // print_r($links); $variables['language']['modal'] = [ 'id' => 'languageModal', 'size' => 'fullscreen', @@ -32,7 +42,8 @@ function oe_whitelabel_preprocess_links__language_block(&$variables) { 'title' => t('Select your language'), 'label' => t('Close'), ], - 'links' => $links, + 'eu_links' => $eu_links, + 'non_eu_links' => $non_eu_links, 'footer' => [ 'label' => t('Close'), ], diff --git a/templates/patterns/modal/modal-language.html.twig b/templates/patterns/modal/modal-language.html.twig index deda0ebd716e07e70ef0dd997dbea07fc3d116f2..bd56b9bdaf4988a00c1517e7ce05bec6fe004099 100644 --- a/templates/patterns/modal/modal-language.html.twig +++ b/templates/patterns/modal/modal-language.html.twig @@ -20,7 +20,7 @@ {% endset %} {% endif %} -{% if links %} +{% if eu_links or non_eu_links %} {% set _body %} <div class="container"> <div class="row"> @@ -29,8 +29,8 @@ </div> </div> <div class="row"> - {% set _number_items = (links|length / 2) %} - {% for link in links|batch(_number_items) %} + {% set _number_items = (eu_links|length / 2) %} + {% for link in eu_links|batch(_number_items) %} {% if loop.index % 2 == 0 %} <div class="col col-lg-4 offset-lg-2"> {% else %} @@ -44,6 +44,28 @@ </div> {% endfor %} </div> + <div class="row"> + <div class="col col-lg-8 offset-lg-2"> + <h5 class="oe-language__title">EU non-official languages</h5> + </div> + </div> + <div class="row"> + {% set _number_items = (non_eu_links|length / 2) %} + {% for link in non_eu_links|batch(_number_items) %} + {% if loop.index % 2 == 0 %} + <div class="col col-lg-4 offset-lg-2"> + {% else %} + <div class="col col-lg-4"> + {% endif %} + <div class="oe-language__list"> + {% for id, name in link %} + <a href="#" class="oe-language__item">{{ name }}</a> + {% endfor %} + </div> + </div> + {% endfor %} + </div> + </div> {% endset %} {% endif %}