diff --git a/README.md b/README.md index 086602cba..d16513e96 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,12 @@ infos: description: "A list of infos of the current page. Deprecated from ECL 2.30." ``` +In addition, the customization that allowed the content language switcher to be rendered inside the page header +has been deprecated in favor of the new [ECL composition](https://europa-component-library.netlify.app/playground/ec/?path=/story/compositions-etranslation--default). +Instead, the OpenEuropa Content Language Switcher block provided by OpenEuropa Multilingual needs to be used +in its place. Sites updating to OpenEuropa Theme V3 are advised to place this block in the page header region +if they wish still need the functionality. + #### Content item compositions We have removed the following compositions from our theme: diff --git a/oe_theme.theme b/oe_theme.theme index 090ab36b4..0466d91e8 100644 --- a/oe_theme.theme +++ b/oe_theme.theme @@ -705,23 +705,15 @@ function _oe_theme_preprocess_languages(array $link_items, string $current_langu * and prepares the links for rendering. */ function oe_theme_preprocess_links__oe_multilingual_content_language_block(array &$variables): void { - $entity = \Drupal::service('oe_multilingual.helper')->getEntityFromCurrentRoute(); - /** @var \Drupal\Core\Entity\EntityInterface $translation */ - $translation = \Drupal::service('oe_multilingual.helper')->getCurrentLanguageEntityTranslation($entity); - $variables['current'] = $translation->language()->getName(); + + // Generate the label for the unavailable language. /** @var \Drupal\Core\Language\LanguageInterface[] $languages */ $languages = \Drupal::service('language_manager')->getNativeLanguages(); - $variables['unavailable'] = $languages[$variables['current_language_id']]->getName(); + $variables['unavailable_language'] = $languages[$variables['current_language_id']]->getName(); // Normalize the links to an array of optional languages suitable for the ECL. - $variables['options'] = []; + $variables['languages'] = []; foreach ($variables['links'] as $language_code => $link) { - - $language_internal = $language_code; - if (EuropeanUnionLanguages::hasLanguage($language_code)) { - $language_internal = EuropeanUnionLanguages::getInternalLanguageCode($language_code); - } - /** @var \Drupal\Core\Url $url */ $url = $link['link']['#url']; $href = $url @@ -729,15 +721,27 @@ function oe_theme_preprocess_links__oe_multilingual_content_language_block(array ->setAbsolute(TRUE) ->toString(); - $variables['options'][] = [ + $variables['languages'][] = [ 'href' => $href, 'hreflang' => $language_code, 'label' => $link['link']['#title'], - 'lang' => $language_internal, + 'current' => FALSE, ]; } - // Generate unique element ID for the expandable component. + // Add the current language to the list. + $multilingual_helper = \Drupal::service('oe_multilingual.helper'); + $entity = $multilingual_helper->getEntityFromCurrentRoute(); + /** @var \Drupal\Core\Entity\EntityInterface $translation */ + $translation = $multilingual_helper->getCurrentLanguageEntityTranslation($entity); + $variables['languages'][] = [ + 'href' => $translation->toUrl()->setAbsolute(TRUE)->toString(), + 'hreflang' => $translation->language()->getId(), + 'label' => $languages[$translation->language()->getId()]->getName(), + 'current' => TRUE, + ]; + + // Generate required ids. $variables['expandable_id'] = Html::getUniqueId('ecl-expandable'); } diff --git a/patches/@ecl/twig-component-page-header-core+3.0.0-beta.1.patch b/patches/@ecl/twig-component-page-header-core+3.0.0-beta.1.patch deleted file mode 100644 index fff2c189f..000000000 --- a/patches/@ecl/twig-component-page-header-core+3.0.0-beta.1.patch +++ /dev/null @@ -1,16 +0,0 @@ -patch-package ---- a/node_modules/@ecl/twig-component-page-header-core/page-header-core.html.twig -+++ b/node_modules/@ecl/twig-component-page-header-core/page-header-core.html.twig -@@ -70,7 +70,11 @@ - extra_classes: 'ecl-page-header-core__breadcrumb', - }) only %} - {% endif %} -- -+ {% if composition is not empty %} -+