Superfish and Menu Token on multilingual site

Created on 11 December 2019, over 5 years ago
Updated 26 July 2023, almost 2 years ago

On my multilingual site after applying patch from here β†’ superfish shows original menu title with non replaced tokens.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine myha

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.

  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work 3 months ago
  • Status changed to Closed: won't fix 8 days ago
  • πŸ‡§πŸ‡ͺBelgium lobsterr

    I think, this is not a problem of superfish module, but menu_token module.
    Menu token module overrides MenuLinkTree class to build the menu tree and replace token.
    So, when MenuLinkTreeMenuToken class builds menu tree:
    it gets the title like this:

    $element['title'] = $link->getTitle();
    

    but in this case we get title from MenuLinkContent class:

      /**
       * {@inheritdoc}
       */
      public function getTitle() {
        // We only need to get the title from the actual entity if it may be a
        // translation based on the current language context. This can only happen
        // if the site is configured to be multilingual.
        if ($this->languageManager->isMultilingual()) {
          return $this->getEntity()->getTitle();
        }
        return $this->pluginDefinition['title'];
      }
    

    As you can see if the content is multilingual, then we take title from the entity and not from plugin definition.
    Menu token modules replaces tokens only in the plugin definitions.

    To conclude it should be correctly handled on Menu toke side then we will get the right value for a title.

    I have just found this!

    You can use solution from this ticket: πŸ› Title replacement not working on multi-language site. RTBC

Production build 0.71.5 2024