Hello,
taxonomy_menu works like a charme. I've created Taxonomy projects with hierarchical structure and translated from german to english. For the setup, I've selected main-menu to put taxonomy_menu in. Just for the notes, I've used language detection by path "/" for german, "/en" for english.
In result, the taxonomy terms urls listed in menu will be in context, but the translation of the menu name is still in german.

thx for some hint...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fragtom created an issue. See original summary.

fragtom’s picture

Issue tags: -tranlation
nerdstein’s picture

Status: Active » Needs review
FileSize
486 bytes

Admittedly, I am not a translation expert. My suspicion is that we need to set the langcode attribute with the menu link definition, aligned with the taxonomy term's language.

I am not sure of the steps to reproduce this, but I am submitting a patch that I believe will resolve this. @fragtom, can you submit steps for me to test (including configuring the translation settings) or can you test the patch?

killua99’s picture

To all this could we add a setting to control the view and only see items (on the menu) on the language you're looking for?

New issue for that?

bisonbleu’s picture

Ok, thanks to @pbuyle and @nerdstein (Drupal North 2016 Sprint), here is a patch that fixes this issue.

Steps to test this patch (how to setup a multilingual taxonomy based menu).

  • I'm assuming you're running a D8 + taxonomy_menu module
  • In modules UI, under Multilingual group, enable Languages, Interface Translation and Content Translation modules
  • at admin/config/regional/language/detection, use path
  • Create a new vocabulary e.g. Animals and add terms e.g. cat, dog, bird...
  • Now translate each term e.g. in French that would be chat, chien, oiseau
  • Now go to admin/config/system/taxonomy_menu and create a taxonomy menu e.g. Animals
  • Set Vocabulary to Animals and Menu to Main navigation
Xano’s picture

The patch itself looks good based on a visual manual review!

I did find the following issues, but those are not touched by this patch. Ideally this patch will include a test, for which the issues below may need to be fixed in order to keep things simple and consistent.

  1. +++ b/src/Plugin/Menu/TaxonomyMenuMenuLink.php
    @@ -94,10 +94,11 @@ class TaxonomyMenuMenuLink extends MenuLinkBase implements ContainerFactoryPlugi
         return NULL;
    

    This method MUST return a string to comply with the interface it implements.

  2. +++ b/src/Plugin/Menu/TaxonomyMenuMenuLink.php
    @@ -107,10 +108,11 @@ class TaxonomyMenuMenuLink extends MenuLinkBase implements ContainerFactoryPlugi
         return NULL;
    

    This method MUST return a string to comply with the interface it implements.

dstol’s picture

Status: Needs review » Needs work

Updating issue status based on Xano's review in #6

esclapes’s picture

Status: Needs work » Needs review
FileSize
5.84 KB

I updated the patch to add tests and solve the concerns on #6.

I have also replaced the deprecated EntityManager for the more suitable alternatives.

Edit: typo

Status: Needs review » Needs work

The last submitted patch, 8: translation_menu_items-2630074-8.patch, failed testing.

esclapes’s picture

Status: Needs work » Needs review
FileSize
7.16 KB
2.98 KB

Fix test fail because of missing @group and auto review of the following:

  • Fix docblocks
  • Rename $link for $term as done by bisonbleu in #5

Status: Needs review » Needs work

The last submitted patch, 10: translation_menu_items-2630074-10.patch, failed testing.

esclapes’s picture

Status: Needs work » Needs review
FileSize
692 bytes
7.22 KB

Sorry, the @cover change was not staged when I diffed the patch.

eloivaque’s picture

#12 m'ha funcionat. Works for me.

PhilY’s picture

Patch #12 works well with Drupal 8.2.6 (at least for term name as I don't use description field).
Thanks

dawehner’s picture

I simplified the code a bit

dawehner’s picture

As a test coverage it feels like having a kernel test would be better. The unit test just proves that the code works like the code looks like.

Status: Needs review » Needs work

The last submitted patch, 15: 2630074-15.patch, failed testing.

Utilvideo’s picture

#15 not working, apply patch #12 work fine

martins.bertins’s picture

Fixed the error introduced by #15.

martins.bertins’s picture

Status: Needs work » Needs review

Forgot to change status.

caw67’s picture

also here: modules works greta, but only without language! i cant edit the menu items and choose the language. and the module seems dont respect the language of my taxonomy terms

LauraRocks’s picture

Sorry I don't have more specific review, but I can confirm that we have a 8.3.2 site that had this problem, #19 fixed it for us and now the names are translated as well. Thank you!

mfrosch’s picture

#19 also works for me - thanks

gaurav.kapoor’s picture

Status: Needs review » Reviewed & tested by the community

#19 Works fine.
1. I added a few taxonomy terms.
2. Enabled multilingual modules and provided translation for taxonomy terms.
3. Switched to language other than english.

And i could see all the menu items rendered in the different language.

Utilvideo’s picture

Tested Work

tien_tia’s picture

Hi martin,
Applied patch in #19 and verified. It work.
Many thanks,

dstol’s picture

Status: Reviewed & tested by the community » Needs work

This needs a rebase against 8.x-3.x.

pfrilling’s picture

Status: Needs work » Needs review
FileSize
1.74 KB

I stepped through @martins.bertins patch from #19 and refactored the code a bit to hopefully make it more clean. My tests seem to be working properly.

gaurav.kapoor’s picture

Status: Needs review » Needs work

Some coding standard issues , otherwise its good for RTBC. Changing to needs work.

dstol’s picture

The patch in #28 and the one in #19 seem to be wildly different. #28 also lacks the tests of #19.

pfrilling’s picture

Status: Needs work » Needs review
FileSize
8.26 KB

The coding standard issues have been fixed. I also wrote a functional test to check the menu for the translated version of the taxonomy term. This was my first attempt at writing a test, so hopefully I did it right.

The code is definitely different than the original patch from #19. While rebasing, I noticed some deprecated function usage and I was trying to update those in the process.

LauraRocks’s picture

I had to update to dev-version because of other fixes committed there, so patch #19 wasn't working anymore. Tried then patch #31 and it seems to do work fine.

  • dstol committed f1c4aec on 8.x-3.x authored by pfrilling
    Issue #2630074 by esclapes, pfrilling, dawehner, martins.bertins,...
dstol’s picture

Status: Needs review » Fixed

Thanks for the contributions everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

eidoscom’s picture

Hi everyone, is the patch already in the 8.x-3.3 stable version? I have problems with translation and want to know before installing the dev version. Thanks!

maxplus’s picture

Thanks,
working with current dev version indeed works as expected: menu items are shown in translated version
(patch #31 does not apply anymore to 8.x-3.3)

Thanks!