Problem/Motivation

When using the Content language detection > Content language plugin, the content admin page does not include the language_content_entity param which is quite confusing for the CMS users as they see the entity label translated but when they click on it, they are redirected to the original language node.

Steps to reproduce

  1. Enable Language and Content Translation modules
  2. Install Spanish language
  3. Access /admin/config/regional/language/detection
    1. Keep only "Selected language" in the "Interface text language"
    2. Check "Customize Content language detection to differ from Interface text language detection settings"
    3. Enable the "Content language"
    4. Uncheck the rest
  4. Access /admin/structure/types/manage/article
    1. Enable translation
  5. Create 2 articles, one for each language
  6. Access admin/content

Result: Notice that the entity label is translated however links don't include the language_content_entity query param and all link to node/{id}.

GIF showing the bug with missing language_content_entity query param

Proposed resolution

TBD

Comments

carolpettirossi created an issue. See original summary.

carolpettirossi’s picture

Issue summary: View changes
StatusFileSize
new3.91 MB
deborahblessy’s picture

StatusFileSize
new3.38 MB

Hi @carolpettirossi,

I have installed Drupal 10, content translation and checked the mentioned issue. I couldn't reproduce the issue mentioned above. I have attached the screen recording below for reference. If any other issue, Please let me know.

I have enabled Spanish language. The url params was passed like [Siteurl]/es/node/2. For English, its [Siteurl]/node/2.

carolpettirossi’s picture

Hi @deborahblessy

Can you please share a screenshot of the "Detection and Selection" page?

It seems for the URLs you shared, that you kept the URL (Language from the URL - Path prefix or domain) enabled. The bug happens only if you don't have that enabled.

See my config page below:
Detection and Selection image showing active config

carolpettirossi’s picture

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

lukas_w’s picture

I can confirm this issue and I have dug a little though the code to find the cause. The content entity language negotiator currently checks, if the path of the current request belongs to an entity and if the outbound path belongs to the same entity. Only in that case the language_content_entity query parameter is added to the outbound URL (i.e. the one used by the edit link).

The admin content page does not belong to any entity and therefore the language_content_entity query parameter is not added to the edit links and the language used on the node edit page is the interface language.

The deeper problem I see is that in processOutbound() the language negotiator cannot really determine, if it should do this or that, since it lacks the context the processed path is used in. The current behavior of the content entity language negotiator could be changed to also add language_content_entity, if the path is the edit-form link of an entity, but I would argue that this brings us only this far.

I maintain a multilingual site, where the URL negotiator is used to determine the interface language. In the backend the interface language should not change when editing a node translation and for that I enabled the content entity negotiator and altered the edit links to add the language_content_entity query parameter. However, in the frontend there should be no difference between interface and content language, but on node pages, the language switcher sets language_content_entity instead of the URL language prefix.

Maybe it would make sense for links (and Urls) to take a language_type option, that defines whether the provided language should be treated as interface or as content language. For the admin content page, the node edit links would use the content language type, whereupon the content entity negotiator would add the language_content_entity query parameter. For the language switcher in my frontend, it would use the interface type and the content entity negotiator would therefore ignore the provided language, leaving it for the URL negotiator to change the interface language.

Would this be a viable solution?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.