Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects

OEL-452: [oe_whitelabel] multilingual

Merged Francesco SARDARA requested to merge OEL-452 into 1.x

Created by: abel-santos-corral

Handled in ticket: OEL-452

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
10 10 "drupal/core": "^8.9 || ^9.1",
11 11 "drupal/ui_patterns": "^1.0",
12 12 "drupal/ui_patterns_settings": "^1.0",
13 "openeuropa/oe_bootstrap_theme": "0.100920211846",
13 "openeuropa/oe_bootstrap_theme": "0.140920211750",
14 14 "openeuropa/oe_authentication": "^1.4",
15 "openeuropa/oe_multilingual": "^1.8",
  • Created by: drishu

    Let's move this one and the oe_authentication to require dev since they are not mandatory for the theme, but for the oe_whitelabel_helper module; Add a short readme in oe_whitelabel_helper, explaning that it adds some blocks and functionality for corporate branding, login, etc and mention there the composer requirements needed to enable the module;

  • Francesco SARDARA
    Francesco SARDARA @brummbar started a thread on commit 48d22393
  • 5 - link
    6 - label
    7 - href
    8 - target
    9 - modal
    10 #}
    11
    12 {% set _language = {
    13 link: {
    14 label: language.link.label|default(''),
    15 href: language.link.href|default('#'),
    16 target: language.link.target|default(language.modal.id|default('')),
    17 },
    18 modal: language.modal,
    19 } %}
    20
  • Francesco SARDARA
    Francesco SARDARA @brummbar started a thread on commit 48d22393
  • 33 {% for link in eu_links|batch(_number_items) %}
    34 {% if loop.index % 2 == 0 %}
    35 <div class="col col-lg-4 offset-lg-2">
    36 {% else %}
    37 <div class="col col-lg-4">
    38 {% endif %}
    39 <div class="oe-language__list">
    40 {% for id, data in link %}
    41 <a id="{{ data.id }}" href="{{ data.href|default('#') }}" class="oe-language__item">{{ data.name }}</a>
    42 {% endfor %}
    43 </div>
    44 </div>
    45 {% endfor %}
    46 </div>
    47 {% if non_eu_links %}
    48 <div class="row">
  • Francesco SARDARA
    Francesco SARDARA @brummbar started a thread on commit 48d22393
  • 11 - links
    12 - footer
    13 - label
    14 #}
    15
    16 {% if header %}
    17 {% set _header %}
    18 <h5 class="modal-title" id="languageeModalLabel">{{ header.title|default('Select your language') }}</h5>
    19 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{{ header.label|default('Close') }}"></button>
    20 {% endset %}
    21 {% endif %}
    22
    23 {% if eu_links or non_eu_links %}
    24 {% set _body %}
    25 <div class="container">
    26 <div class="row">
  • Francesco SARDARA
  • Francesco SARDARA
    Francesco SARDARA @brummbar started a thread on commit 48d22393
  • 96 $crawler = new Crawler($render->__toString());
    97
    98 $block = $crawler->filter('#block-languageswitcherinterfacetext');
    99 $this->assertCount(1, $block);
    100 $link = $crawler->filter('a.nav-link');
    101 $this->assertSame('English', trim($link->text()));
    102 $this->assertSame('English', $link->attr('href'));
    103 $title = $crawler->filter('h5#languageeModalLabel');
    104 $this->assertSame('Select your language', $title->text());
    105 $button_header = $crawler->filter('button.btn-close');
    106 $this->assertSame('Close', $button_header->attr('aria-label'));
    107 $title = $crawler->filter('h5.oe-language__title');
    108 $this->assertSame('EU official languages', $title->text());
    109 $link_language = $crawler->filter('a#link_en');
    110 $this->assertSame('/en/<none>', $link_language->attr('href'));
    111 $this->assertSame('English', $link_language->text());
    • Created by: drishu

      we can copy paste the check for english in the modal and assert all languages from there (do it statically, dont load languages and no loops pls, one by one copy-paste and edit

  • Francesco SARDARA
  • Francesco SARDARA
  • Francesco SARDARA
  • Francesco SARDARA
  • Francesco SARDARA
    Francesco SARDARA @brummbar started a thread on commit 48d22393
  • 13 function oe_whitelabel_preprocess_links__language_block(&$variables) {
    14 /** @var \Drupal\Core\Language\LanguageInterface[] $original_languages */
    15 $original_languages = \Drupal::service('language_manager')->getNativeLanguages();
    16 $currentLanguage = \Drupal::languageManager()->getCurrentLanguage()->getName();
    17 $variables['language']['link'] = [
    18 'label' => $currentLanguage,
    19 'href' => $currentLanguage,
    20 'target' => 'languageModal',
    21 ];
    22
    23 $eu_links = [];
    24 $non_eu_links = [];
    25 foreach ($original_languages as $language) {
    26 $url = $variables['links'][$language->getId()]['link']['#url'];
    27 $host = \Drupal::request()->getHost();
    28
    • Created by: drishu

      construct a link object instead of initializing almost the same render array twice

      $link = [
            'href' => $href,
            'name' => $label,
            'id' => 'link_' . $language_code,
            'hreflang' => $language_code,
          ];
  • Francesco SARDARA
  • Francesco SARDARA
  • Francesco SARDARA
  • Francesco SARDARA
  • Francesco SARDARA
  • Francesco SARDARA
    Francesco SARDARA @brummbar started a thread on commit 48d22393
  • 47 unset($variables['links']);
    48 $variables['language']['modal'] = [
    49 'id' => 'languageModal',
    50 'size' => 'fullscreen',
    51 'header' => [
    52 'title' => t('Select your language'),
    53 'label' => t('Close'),
    54 ],
    55 'eu_links' => $eu_links,
    56 'non_eu_links' => $non_eu_links,
    57 'footer' => [
    58 'label' => t('Close'),
    59 ],
    60 ];
    61 unset($variables['links']);
    62
  • Francesco SARDARA
  • Francesco SARDARA
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading