Problem/Motivation
Some Sites require switching of content languages whilst site interface is another - i.e. approvers for multilingual content.
When using Content language detection, menu blocks follows content language negotiation. For most/some projects - menus are part of the site interface and therefore we should have an easier way to choose whether to follow site interface or content negotiation.

How to Reproduce
1. Add Languages (zh-hant)
2. Interface text language detection - Choose URL
3. Check - Customize Content language detection to differ from Interface text language detection settings
4. Content language detection - Selected language (zh-hant)
5. In both En and zh-hant sites - all menu blocks will be zh-hant

Possible Clauses

Proposed resolution
A suggestion would be , which Content Language Detection is enabled. Allow choosing whether language negotiation is based on Site Interface OR Content for that Menu .. Default is Content?

Remaining tasks

User interface changes

API changes

Issue fork drupal-3101747

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

xenyo created an issue. See original summary.

xenyo’s picture

Title: When Content Language Detection is enabled, menu is forced to follow Content when Site Interface is the preferred choice sometimes. » When Content Language Detection is enabled, menus are forced to follow Content when Site Interface is the preferred choice sometimes.
kt2ssh’s picture

StatusFileSize
new1.28 KB
kt2ssh’s picture

StatusFileSize
new952 bytes
ravi.shankar’s picture

Status: Needs work » Needs review
kt2ssh’s picture

StatusFileSize
new5.06 KB

Hi , here is the new patch, it is now configurable from "Content Entity Negotiation" :

1. install new drupal 8.9-dev
2. enable language & content translation module
3. /admin/config/regional/language , add a new language (Chinese, Traditional)
4. /admin/config/regional/language/detection , enable "Content language detection", enable "Content language" and drag it to the top
5. /admin/structure/types/manage/article , check "Enable translation"
6. /node/add/article , add a new article with translation (both en and zh-hant)
7. /admin/structure/menu/manage/main , add a new menu "home" with link "< front >", then translate the menu as "首頁"
8. /admin/config/regional/content-language, enable "Custom menu link" and check all fields under this section
9. /zh-hant/node/1?language_content_entity=en visit the article just created (using zh-hant url prefix), you will see that both article content and the newly created "home" menu are showing in zh-hant language, however menu should follow the user interface language instead of the content.
10. apply the patch "3101747-7.patch"
11. /admin/config/regional/language/detection/content-entity, here is a new option "Force menu follow Interface Language" , check this option and save.
12. flush all caches
13. /zh-hant/node/1?language_content_entity=en , now the content is showing english version and the menu is showing as zh-hant language

kt2ssh’s picture

StatusFileSize
new5.3 KB
sutharsan’s picture

Assigned: xenyo » Unassigned

@xenyo, Did you intentionally assign the issue to yourself? Did you forget to turn it off? See https://www.drupal.org/node/2172049 about how to use the 'Assigned' to field of an issue.

I'm un-assigning you, assuming it was not intentionally and you have not been active in this queue for two almost weeks. Feel free to re-assign if my assumption was wrong.

xenyo’s picture

Assigned: Unassigned » xenyo

Yeah thx @Sutharsan. kt2ssh is in our same company and I was helping him open an issue .

We are not that familier with contributing so thx for the help. For this issue, do we just wait for review or is there anything else we can help.

xenyo’s picture

Assigned: xenyo » Unassigned

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

madhu_h’s picture

StatusFileSize
new146.39 KB

Verified and tested the Merge request !
https://www.drupal.org/files/issues/2019-12-27/3101747-7.patch

Testing Steps:
. install new drupal 8.9-dev
2. enable language & content translation module
3. /admin/config/regional/language , add a new language (Chinese, Traditional)
4. /admin/config/regional/language/detection , enable "Content language detection", enable "Content language" and drag it to the top
5. /admin/structure/types/manage/article , check "Enable translation"
6. /node/add/article , add a new article with translation (both en and zh-hant)
7. /admin/structure/menu/manage/main , add a new menu "home" with link "< front >", then translate the menu as "首頁"
8. /admin/config/regional/content-language, enable "Custom menu link" and check all fields under this section
9. /zh-hant/node/1?language_content_entity=en visit the article just created (using zh-hant url prefix), you will see that both article content and the newly created "home" menu are showing in zh-hant language, however menu should follow the user interface language instead of the content.
10. apply the patch "3101747-7.patch"
11. /admin/config/regional/language/detection/content-entity, here is a new option "Force menu follow Interface Language" , check this option and save.
12. flush all caches
13. /zh-hant/node/1?language_content_entity=en , now the content is showing english version and the menu is showing as zh-hant language

Test Results:
There is an error while applying patch

Refer SS

Test Status: FAIL

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

lobsterr’s picture

ranjith_kumar_k_u’s picture

StatusFileSize
new4.78 KB
new214 bytes
kristen pol’s picture

Thanks for the updated patch. Tagging for manual testing and to add tests.

kristen pol’s picture

Status: Needs review » Needs work

Moving back to needs work for tests.

nicolas s.’s picture

Patch works with an D9.3.9

lobsterr’s picture

Status: Needs work » Needs review
StatusFileSize
new9.66 KB
new4.87 KB

I added tests

Status: Needs review » Needs work

The last submitted patch, 21: 3101747-21.patch, failed testing. View results

lobsterr’s picture

Status: Needs work » Needs review

The tests fail, but it is not related to the current issue. I assume something is broken on the tests system

ambikahirode’s picture

StatusFileSize
new618.67 KB
new618.67 KB

#21 working For me on local 9.4
Verified and tested the issue by applying patch 3101747-21.patch .
Patch was successfully applied and issue got fixed.refer Screenshot

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

simohell’s picture

Issue tags: +Usability
sonnykt’s picture

StatusFileSize
new1.05 MB
new1.05 MB
new1.05 MB
new1.04 MB
new1.05 MB
new1.05 MB
new1.01 MB
new1.01 MB

Manual test results on Drupal 9.5.x-dev.

Testing steps

* Enable Language and Content Translation module
* Set default site language to English
* Regional & Language > Languages /admin/config/regional/language: add "Chinese, Traditional" (zh-hant)
* Regional & Language > Detection and selection /admin/config/regional/language/detection: enable URL in "Interface text language detection", enable "Customize Content language detection...", enable "Content language" in "Detection method" and move it to the top.
* Regional & Language > Content language and translation /admin/config/regional/content-language: enable "Custom menu link" and check Menu link title, Description, and Changed.
* Enable translation for content types.
* Add a node in English, and add a Chinese translation
* Add a menu link for the created node in English, and add a Chinese translation for the menu link.

On Drupal 9.5.x without any patch:

* UI language: En /first-page - menu shows links in English, content shows English
 EN
* UI language: En - Content language: En /first-page?language_content_entity=en - menu shows English links, content shows English
 EN
* UI language: En - Content language: Zh /first-page?language_content_entity=zh-hant - menu shows English links, content shows Chinese
 ZH
* UI language: Zh /zh-hant/first-page - menu shows links in Chinese, content shows Chinese
 ZH
* UI language: Zh - Content language: En /zh-hant/first-page?language_content_entity=en - menu shows links in Chinese, content shows English
 ZH
* UI language: Zh - Content language: Zh /zh-hant/first-page?language_content_entity=zh-hant - menu shows links in Chinese, content shows Chinese
 ZH

Vanilla Drupal 9.5.x works quite consistent and I don't think it is an issue.

After applying patch #21:

* UI language: En /first-page - menu shows links in English, content shows English
 EN
* UI language: En - Content language: Zh /first-page?language_content_entity=zh-hant - menu shows Chinese links, content shows Chinese
 ZH
* UI language: Zh /zh-hant/first-page - menu shows links in Chinese, content shows Chinese
 ZH
* UI language: Zh - Content language: En /zh-hant/first-page?language_content_entity=en - menu shows Chinese links, content shows Chinese
 EN

With patch #21, the results are not consistent. The menu shows Chinese links when UI:En and Content:Zh, but it does not show English links when UI:Zh and Content:En.

simohell’s picture

Hi,

Thanks @sonnykt

We discussed this a while ago with the Drupal UX group. I was just about to ask for some screenshots and more detailed instruction as we were not able to reproduce this testing using an Umami demo installation.

I wonder if this is theme specific issue?

sonnykt’s picture

Hi @simohell,

I was testing the issue with the standard profile and theme Bartik.

kristen pol’s picture

Status: Needs review » Needs work
Issue tags: -Needs manual testing

Thanks for testing and the feedback.

Moving back to needs work based on above. Maybe this needs the UX group to take another look?

kristen pol’s picture

Issue tags: -Needs tests

Tests were added so removing tag.

lobsterr’s picture

Assigned: Unassigned » lobsterr

I will check the cases described in #27

lobsterr’s picture

After reproducing one to one the steps and results provided on the screenshots in #27 with 9.5.x.
I have different results. The patched version works as it should and not patched is not consistent.
I introduced steps, which are different for me.

Clean Drupal 9.5.x

1) /first-page?language_content_entity=zh-hant

Content: Chinese
Menu: Chinese

2) /zh-hant/first-page?language_content_entity=en

Content: English
Menu: English

Patched Drupal 9.5.x

1) /first-page?language_content_entity=zh-hant

Content: Chinese
Menu: English

2) zh-hant/first-page?language_content_entity=en

Content: English
Menu: Chinese

So, to sum up. For me the patch works as expected.

@sonnykt Could you please double check or someone else ?
On my side I did it several times.

Thank you in advance

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

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

lobsterr’s picture

Version: 11.x-dev » 10.2.x-dev
Assigned: lobsterr » Unassigned
Status: Needs work » Needs review
StatusFileSize
new9.74 KB

Reroll the patch for 10.2

smustgrave’s picture

Version: 10.2.x-dev » 11.x-dev
Status: Needs review » Needs work

11.x is the current development branch.

It's recommended to use MRs as patches are being phased out and don't automatically run anymore. Will manually trigger but see that new functions should have a return typehint, didn't do a full review though.

lobsterr’s picture

Status: Needs work » Needs review

Thanks for info, I have created a MR

smustgrave’s picture

Hiding patches for clarity.

Left some comments but also appears to have a test failure.

smustgrave’s picture

Status: Needs review » Needs work

pierreemmanuel made their first commit to this issue’s fork.

pierreemmanuel’s picture

StatusFileSize
new5.07 KB

Hi,
Here is the reroll of patch #36 for drupal 10.3.x.
Regards

erwangel’s picture

Sorry for the long post that follows but I found this is the most mature issue resolution and I hope my test and comments may contribute to further clarify the problem and improve its solution.

It seems that menus are displayed in their original or interface language or content language according to their provenance (how where they generated). In some cases this can lead to mixture of translated and untranslated menus. But the problem is not only in menus, displaying of block titles, field labels can also create a language confusion.

I am of the opinion that switching content language should not affect the interface (menus, blocks titles and content, any links, etc.) and only change the main content (node or views listing), not event the entire page content (related blocks and other extra content), i.e. only change what is called the "Main page content" in block layout. This opinion because users may be able to read an article in various languages but have a preferred language for the user interface and the rest of the content. They just occasionally prefer read an article in a language different of their usual language. An American-spanish-speaken citizen may want its site in English but if an article is published in both English and Spanish he may prefer read the article in Spanish without seen the entire site switched in Spanish. I think that is the main reason for separating interface and content translation.

Now here my observations on a D10.4 installation before applying the patch.
Configuration: fr (french default), en (English), de (Deutsch - German)
Interface detection: from url (path prefix)
Content detection: content language (request parameter 'language_content_entity')

In order to avoid fastidious repetitions, I defined tree types of menus:
- TYPE 1: menu links provided by the Standard module (ex. "Home" link) or by Views or by Taxonomy Menu module (you can not edit nor translate them in "admin/structure/menu")
- TYPE 2: menu links provided by nodes ("Provide a menu link" option in node's edit page and you can also edit/translate in "admin/structure/menu") or empty links ( to display link text only)
- TYPE 3: any other menus manually created and translated in "admin/structure/menu" either with internal path or a node link they

Cases:
* Interface FR (default), no request param
- url: /page-fr-url (aliased on node's title) => content, content field labels, menus, blocks in FR as expected

* Interface FR (default), language_content_entity=FR
- url: /page-fr-url?language_content_entity=fr => same as above as expected

* Interface FR, language_content_entity=EN (or DE)
- url: /page-fr-url?language_content_entity=en
- Content is displayed in content language (EN), field labels too, block title and content are in interface language (FR)
- Menus TYPE 1 titles: respect the interface language (fr)
- Menus TYPE 2 titles: they follow the content language (en).
- Menus TYPE 3 titles: they follow the content language (en)
- All Menu urls are build according to the interface language (fr is default so no prefix in url)
- Local task tabs respect the Interface language (fr)
As Result: A confusing mixture of menus translated in one or other language!

* Interface language EN, no request param
- url: /en/page-en-url (aliased on node's title)
- Content shows in default FR (content lang) but field labels in EN! (interface lang), block titles in interface language EN
- Menus TYPE 1 respect the interface language (EN)
- Menus TYPE 2 and 3 are in... default FR! even when both the menu text the linked page have a translation in the current interface language
- All Menu urls are build according to the interface language (/en/___)
- Local tasks respect interface (EN)
--- Note 1: In untranslatable and in untranslated nodes, same behavior as above (mixed translations)
--- Note 2: In Views pages, all menu types are displayed as expected in the interface language
Conclusion: it is like the lack of language_content_entity parameter has a fallback to the default content language.There may be some logic here too but ths leads to unexpected result: having make no choice about content language one could expect that the entire page would be in the interface chosen language.

* Interface language EN, language_content_entity=FR (default)
- url: /en/page-en-url?language_content_entity=fr => Same as with no request parameter

* Interface language EN, language_content_entity=EN
- url: /en/page-en-url?language_content_entity=en => everything is in English

* Interface language EN, language_content_entity=DE (default FR language is not implied in interface nor in content)
- url: /en/page-de-url?language_content_entity=de
- Content displays in the content language (DE), block titles are in interface language EN even those placed inside content with layour builder (I think they should be consistent with the rest of node's content, i.e. have the content language DE)
- Menus TYPE 1 respect the interface language (EN)
- Menus TYPE 2 and 3 follow the content language (DE)
- All Menu urls are build according to the interface language (/en/___)
- Local tasks respect interface (EN)

Conclusion

There is no validation of language_content_entity's value at least from user's point of view. You can set manually whatever you want, numbers, letters, special characters, you never get an error message.

In views content (pages and blocks): In views you have different choices for the Rendering Language, but titles will display according to the interface language.

Content blocks:
Added on a page with block layout (/admin/structure/block): title in interface language, content in content language.
Added in a node with layout builder (/node/nid/layout): no way to translate the title, content in content language

In node's full mode: title and content they display in the content language but field labels and views blocks inserted with layout builder are in the interface language. If I a am able to understand the content in one language I am able to understand the fields labels and the block titles too no? Are Field labels and block titles part of the interface or do they belong to the content ? (I am for the second option)

Menus: titles obey to the interface language if links were generated by a module, but they obey to the content language if they were generated by a node or "by hand". In any case, the underlying url is build according to the interface language. So you can have a link whose text is in German but the url is the English one. Once you click it the interface will switch to English. Not necessarily what is desired.

What can we do ?

I know there have been long discussions about content and interface translation. Looking to the current situation and the several patches here and there that try to resolve one or an other problem, It doesn't seem like it clarified anything. I think we have to radically simplify and consider that
1) Only menus, action links and buttons are part of the interface and they should behave according to the interfae language regardless their provenance.
2) Block title and Field label's function is to announce what follows, i.e. content. So they should be considered as content and display according to the content language
3) Have the option to apply content translation only to what is called the "Main page content" in block layout or to the entire page
4) Menu link titles and underlying urls should be language complaints
4) Verify that language_content_entity value validates against the available language, otherwise throw an error

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.