Language icons not working with Language Switcher Menu

Created on 12 July 2022, over 2 years ago
Updated 27 July 2024, 5 months ago

Language Switcher Menu giving issues with Language Icons. It is printing just text array as string. Issue seems to be MenuLinkDefault which is extended by Language Icons in class LanguageSwitcherLink. It is returning title as string. We will have to override the function getTitle in LanguageSwitcherLink, and return array.

Attached is the patch.

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇮🇳India manojbisht_drupal

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom John_B London (UK), Worthing (UK), Innsbruck (Tirol)

    This patch is not working because dev (and the current production version, beta 5) includes a getTitle() and the patch triggers a "cannot redeclare getTitle()" error and WSOD.

  • 🇩🇪Germany FeyP

    As mentioned in a previous comment, the patch no longer applies to the latest release. Also, and this is already mentioned indirectly in the issue summary, the requirement to return a string for menu link titles is a limitation of the Drupal API. It might or might not be possible to return a render array for now without core patches (I didn't look into this in detail, yet), but if it works right now it is not at all certain that this would continue to work in the future.

    We might actually be able to include a fix for this where we try to render any render array for the link title into a string in isolation and then return the rendered string as the title of the menu link. It is not certain that this would work, but it is worth a try. Anyway, unless someone provides an MR with test coverage, I would need an example of the way the menu link is altered to show the icons, so that I can look into this further. This could either be steps to reproduce with a contributed module, contributed theme, or more information on how this has been implemented in custom code.

Production build 0.71.5 2024