Pass language object as an option to the URL

Created on 24 June 2019, over 5 years ago
Updated 25 September 2024, 5 months ago

We are facing an issue in our multilingual domains setup. The add translation link behaves quite differently than the link provided by content_translation module. While the content translation module switches the domain to add a translation, views_entity_translations_links doesn't. The reason the missing language option parameter. See \Drupal\content_translation\Controller\ContentTranslationController::overview() for reference:

        $options = ['language' => $language];
        $add_url = $entity->toUrl('drupal:content-translation-add', $options)
          ->setRouteParameter('source', $original)
          ->setRouteParameter('target', $language->getId())

I think we should also pass the language option to get a consistent behaviour.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇨🇭Switzerland dermario Zürich

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.

  • 🇫🇷France Jérôme Dehorter Lille

    Hi,
    I encountered the same problem with the 2.0.0 branch. I am attaching the patch to resolve this issue.

  • 🇧🇪Belgium Ozmodiar

    Hello Jérôme

    Can you maybe provide a few steps in order to reproduce this issue? Because with the info provided, I'm unable to reproduce this... and therefore cannot verify if the patch actually solves the issue.

    Thanks in advance!

  • Status changed to Postponed: needs info 12 days ago
  • 🇫🇷France nico972 Lille

    Hi,
    this patch fix also pending revisions with moderation state and add destination URL.

  • 🇫🇷France Jérôme Dehorter Lille

    Hi jvandooren,
    Sorry for the late response.
    On our site we have 2 languages, French by default and English second. Without the patch, when I click on the English flag to translate, I am redirected to the translation page in /fr, which is not a problem as long as there is no relational field like media or other content. The relational fields offer media in French and we want to have media in English or other English content which is not possible because autocomplete does not display them.

    The patch therefore forces when clicking on the English flag on the translation page in /en which displays the correct content or media in the language chosen by clicking on the flag.

    Have a good day.

Production build 0.71.5 2024