Problem/Motivation

It is currently not possible to translate a node and assign different translations of that node to different menus, such as when you have a "Main menu (English)" menu and a "Main menu (French)" menu that are not translations of each other, with different structures.

Proposed resolution

Make the fields translatable.

Remaining tasks

Decide on an approach
Patch
Tests
Review

User interface changes

Fields are available for translation now ("menu name" and "parent plugin ID" should probably be combined into "parent" in the UI):

API changes

Data model changes

weight, parent, menu_name fields become translatable on menu link content

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stefan.r created an issue. See original summary.

stefan.r’s picture

Status: Active » Needs review
FileSize
1.7 KB

I wonder if we should also make some of the other fields translatable (link, external, enabled, ..)

timmillwood’s picture

Looks good, glad it worked.

I wonder if there's a reason not to make everything translatable.

Status: Needs review » Needs work

The last submitted patch, 2: 2858201-1.patch, failed testing.

jofitz’s picture

Status: Needs work » Needs review
FileSize
1.7 KB

Re-rolled.

stefan.r’s picture

Adding some tests and an update hook

stefan.r’s picture

The last submitted patch, 6: 2858201-6.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 7: 2858201-7.patch, failed testing.

stefan.r’s picture

Status: Needs work » Needs review
FileSize
6.75 KB

This doesn't update menu_tree correctly yet, only data from whichever translation was last saved is stored currently

dawehner’s picture

+++ b/core/modules/menu_ui/src/Tests/MenuNodeTest.php
@@ -311,31 +321,48 @@ public function testMultilingualMenuNodeFormWidget() {
+
+    // Assert that the original link exists in the frontend.
+    $this->drupalGet('node/' . $node->id(), array('language' => $languages[$langcodes[0]]));
+    $this->assertLink($node_title);
...
+    // Assert that the translated link exists in the frontend.
+    $this->drupalGet('node/' . $node->id(), array('language' => $languages[$langcodes[1]]));
+    $this->assertLink($translated_node_title);

Is it just me that this test coverage is a bit weak? Can't we ensure that the link is actually available in the two separate selected menus?

stefan.r’s picture

Discussing this on IRC with @pwolanin, this patch is probably not the right approach.

He's suggesting a menu link field (#2315773: Create a menu link field type/widget/formatter) and patching the node menu widget to allow for a separate menu link per translation (rather than translating menu links themselves).

pwolanin’s picture

Yes, we should close this issue I think

stefan.r’s picture

Status: Needs review » Closed (won't fix)