Active language not shown

Created on 7 November 2023, about 1 year ago
Updated 1 August 2024, 4 months ago

Hi, I used this module on several Drupal 9 installations. I set the config, so that the active language should be shown - but not linked.
On Drupal 10 I can't display the active language as soon I enable this module. Using core language switcher, both languages (DE + ENI) are shown.
I use this together with bootstrap_barrio / bootstrap_sass
Anyone else seeing this problem?
Anything which is different on Drupal 10?

šŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

šŸ‡©šŸ‡ŖGermany vistree

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @vistree
  • šŸ‡¬šŸ‡§United Kingdom jacobupal Leeds

    I seem to have a similar issue, Drupal 10.1.6, I believe recent updates split the language switcher into two switchers, one for interface and one for content.

    I think my short-term solution will be to try and prevent pointer events with css, but I would appreciate this being fixed.

    Here's how the settings are panning out for me:

    Content Language Switcher (using Content Language Parameter) with language_switcher_extended settings:
    ā”‚
    ā””ā€”ā†’ Untranslated Handler:  'Hide the switcher link'
    ā”‚   ā””ā€”ā†’ SUCCESS
    ā”‚
    ā””ā€”ā†’ Untranslated Handler:  'Display the language without link'
    ā”‚   ā””ā€”ā†’ !!!Untranslated Language is not displayed!!!
    ā”‚     ā””ā€”ā†’ Hide single link block: True
    ā”‚       ā””ā€”ā†’ !!!Block with single link is not hidden!!!
    ā”‚
    ā””ā€”ā†’ Current language mode: 'Hide the language Switcher Link'
    ā”‚   ā””ā€”ā†’ SUCCESs
    ā”‚
    ā””ā€”ā†’ Current language mode: 'Display the language without link'
        ā””ā€”ā†’ !!!Link is still there!!!
    
    Interface Language Switcher (using URL) with language_switcher_extended settings:
    ā”‚
    ā””ā€”ā†’ Untranslated Handler:  'Hide the switcher link'
    ā”‚   ā””ā€”ā†’ SUCCESS
    ā”‚
    ā””ā€”ā†’ Untranslated Handler:  'Display the language without link'
    ā”‚   ā””ā€”ā†’ !!!Untranslated Language is not displayed!!!
    ā”‚     ā””ā€”ā†’ Hide single link block: True
    ā”‚       ā””ā€”ā†’ !!!Block with single link is not hidden!!!
    ā”‚
    ā””ā€”ā†’ Current language mode: 'Hide the language Switcher Link'
    ā”‚   ā””ā€”ā†’ Wrong language is hidden (content language is hidden, should be interface language)
    ā”‚
    ā””ā€”ā†’ Current language mode: 'Display the language without link'
        ā””ā€”ā†’ !!!Link is still there!!!
    
  • šŸ‡©šŸ‡ŖGermany vistree

    No activity here. I think I will remove the module and look for a different one.

  • šŸ‡øšŸ‡®Slovenia MrMiso

    Same problem. If you select Select language without link the whole language gets remove instead of just removing the link.

  • šŸ‡øšŸ‡®Slovenia MrMiso

    I checked the code and I also used the bootstrap theme and I found the following.

    If code removes url (unset($links[$langcode]['url'])) then at least in bootstrap theme the link doesn't get generated as one of links available to links.html.twig through links variable. It is a bit dirty hack but I removed unset of url and overrided the links twig for language block as following:

    links--language-block.html.twig

    {% if links -%}
      {%- if heading -%}
        {%- if heading.level -%}
          <{{ heading.level }}{{ heading.attributes }}>{{ heading.text }}</{{ heading.level }}>
        {%- else -%}
          <h2{{ heading.attributes }}>{{ heading.text }}</h2>
        {%- endif -%}
      {%- endif -%}
      {%- if attributes.hasClass('inline') -%}
      <ul{{ attributes.addClass('list-inline') }}>
      {%- else -%}
      <ul{{ attributes }}>
      {%- endif -%}
        {%- for key, item in links -%}
          <li{{ item.attributes.addClass(key|clean_class) }}>
            {%- if item.link and not item.text_attributes.hasClass('language-link--untranslated') -%}
              {{ item.link }}
            {%- elseif item.text_attributes -%}
              <span{{ item.text_attributes }}><s>{{ item.text }}</s></span>
            {%- else -%}
              <s>{{ item.text }}</s>
            {%- endif -%}
          </li>
        {%- endfor -%}
      </ul>
    {%- endif %}
    

    Basically if it has untranslated class output it as a text instead of link.

  • Status changed to Needs review 9 months ago
  • Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • šŸ‡©šŸ‡ŖGermany szeidler Berlin

    Thanks for your detailed issue description, especially @MrMiso.

    There must have indeed been a change in the language switcher rendering of links in Drupal 10, so that a link without the `#url` property is not rendered at all anymore.

    Luckily there is a `<nolink>` route that can be used for achieving what we wanted. It seems that all your reported failures have been related to the wrong `<nolink>` handling.

    Could you give the following patch a try?

  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 10.2.1 + Environment: PHP 8.2 & sqlite-3.34
    last update 9 months ago
    9 pass
  • šŸ‡¬šŸ‡§United Kingdom idmacdonald

    Hi,

    This patch in post #6 fixed the problem for me. Thanks for that. As far as I'm concerned, this quite small patch should be merged into the module code.

  • Status changed to RTBC 4 months ago
  • šŸ‡©šŸ‡ŖGermany szeidler Berlin
    • szeidler ā†’ committed e686bb07 on 8.x-1.x
      Issue #3399918 by szeidler, vistree, MrMiso, idmacdonald, jacobupal:...
  • Status changed to Fixed 4 months ago
  • šŸ‡©šŸ‡ŖGermany szeidler Berlin

    I committed the changes. Thanks for your inputs!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024