Return translated term name on views "Content: Has taxonomy term ID (with depth)"

Created on 13 July 2016, over 8 years ago
Updated 4 July 2024, 6 months ago

Problem/Motivation

From the original bug report:
I have a view that lists nodes, filtered by contextual filter "Content: Has taxonomy term ID (with depth)".
In the view I override the view title in the contextual filter setting with "{{ arguments.term_node_tid_depth }}" token.

All the terms have translation, but I noticed that the title is always displayed in the default language.

Title should be displayed in current active translation.

Steps to reproduce

  • Enable content_translation module
  • add Spanish language
  • Enable content translation to Spanish for taxonomy terms
  • Create a taxonomy term (e.g. Butterfly) and translate it into Spanish (Mariposa)
  • Change the taxonomy_term view to use the "Has taxonomy term ID (with depth)" argument, as well as the depth
  • Ensure that "Replace title" is checked, and {{ arguments.term_node_tid_depth }} is used as the title replacement
  • Go to the taxonomy term page in Spanish
  • The English title will be shown instead of Spanish - this is the bug.


Proposed resolution

- In the views argument plugins, fetch the translation from context and try to get the label from translation.

Remaining tasks

Needs review

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

🐛 Bug report
Status

Fixed

Version

10.3

Component
Taxonomy 

Last updated 1 day ago

  • Maintained by
  • 🇺🇸United States @xjm
  • 🇬🇧United Kingdom @catch
Created by

🇫🇮Finland heikki

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada joseph.olstad

    While we do have test coverage, Lendude mentioned that one additional test is required.

  • Pipeline finished with Failed
    10 months ago
    Total: 184s
    #96223
  • Pipeline finished with Canceled
    10 months ago
    Total: 105s
    #96226
  • Pipeline finished with Failed
    10 months ago
    Total: 193s
    #96230
  • Pipeline finished with Failed
    10 months ago
    Total: 471s
    #96234
  • Pipeline finished with Failed
    10 months ago
    #96245
  • 🇨🇦Canada joseph.olstad

    Pretty sure to fix the tests this yml file needs to be updated in a vanilla install of D11 or D10.2

    core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.taxonomy_translated_term_name_test.yml

  • Pipeline finished with Success
    10 months ago
    Total: 586s
    #105739
  • Status changed to Needs review 10 months ago
  • 🇮🇳India mohit_aghera Rajkot

    - Tests are green now.
    There was one deprecated config change in view. Sorted that out.

    - Updated issue summary and moving it to Needs Review
    - Removed Needs test tag since it is not required anymore.

  • Status changed to Needs work 10 months ago
  • 🇮🇳India mohit_aghera Rajkot

    Working on the test coverage for the second plugin.

  • Pipeline finished with Failed
    10 months ago
    Total: 171s
    #105812
  • Pipeline finished with Success
    10 months ago
    Total: 1080s
    #105820
  • Status changed to Needs review 10 months ago
  • 🇮🇳India mohit_aghera Rajkot

    - Added the test case for the another ViewsArgument plugin.
    - Tests are passing on local as well as CI
    - Unusual failure form nightwatch tests, triggered the job again.

  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Status changed to Needs review 10 months ago
  • Pipeline finished with Success
    10 months ago
    Total: 591s
    #106040
  • Status changed to RTBC 10 months ago
  • 🇨🇦Canada joseph.olstad

    @mohit_rocks , thanks for the work on the tests! Marking this as ready.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Hiding all the patch files since this issue is using an MR.

  • Status changed to Needs work 10 months ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Added some review comments to the MR. This is a nice - we need to take care of classes that extend the core classes and I think there is a slightly better way of doing things.

  • Pipeline finished with Canceled
    10 months ago
    #112601
  • Pipeline finished with Failed
    10 months ago
    Total: 163s
    #112602
  • Pipeline finished with Success
    10 months ago
    Total: 477s
    #112652
  • Pipeline finished with Success
    10 months ago
    Total: 516s
    #112678
  • Pipeline finished with Success
    10 months ago
    Total: 482s
    #114756
  • Status changed to Needs review 10 months ago
  • 🇮🇳India mohit_aghera Rajkot

    Addressed the PR feedback.
    I think https://git.drupalcode.org/project/drupal/-/merge_requests/6625#note_276326 would need some verification while doing review.
    I'm somewhat confused about that.

    Other point seems clear.

  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Status changed to Needs review 10 months ago
  • Pipeline finished with Success
    10 months ago
    Total: 549s
    #115046
  • Status changed to RTBC 10 months ago
  • 🇨🇦Canada joseph.olstad

    ok, it's clean now.
    RTBC

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    I've made a mistake here. DeprecatedServicePropertyTrait doesn't support entity storages. I'll fix the MR.

  • Pipeline finished with Success
    10 months ago
    Total: 662s
    #119060
  • 🇮🇳India mohit_aghera Rajkot

    @alexpott do we need a change record for this one?

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    @mohit_aghera - yes we should have something small and simple... and the @see should point to it and not this issue. Great catch.

    Can you add one, fix the MR and then set this back to RTBC?

  • Status changed to Needs work 10 months ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Here's an example MR doing the same thing... https://www.drupal.org/node/3397213

  • Pipeline finished with Success
    10 months ago
    Total: 1557s
    #119116
  • Status changed to RTBC 10 months ago
  • 🇮🇳India mohit_aghera Rajkot

    Change record created. Back to RTBC

  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • First commit to issue fork.
  • Status changed to RTBC 10 months ago
  • 🇮🇳India adwivedi008

    Resolved the coding standard issue at last Pr due to which the pipeline was failing and setting back the status to RTBC from Needs works

    Please review and suggest if any other changes are required.

  • Pipeline finished with Failed
    10 months ago
    Total: 1011s
    #119641
  • 🇮🇳India mohit_aghera Rajkot

    @adwivedi008, can you please be sure that we need to fix the issues?

    Reason is comment in #100is saying that patch is no longer applied to the core.
    In this case, you need to merge latest 11.x to the branch.
    I tried that and it seemed to be working fine.

  • Pipeline finished with Failed
    10 months ago
    Total: 14694s
    #119647
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    @adwivedi008 your fixes are not fixes - core's coding standards are checked on every commit to an MR - the pipeline was green after #99 but your changes broke the pipeline. The "drupal" coding standard as detailed by coder is not the the core coding standard. Core is working towards it but we should never make out of scope changes to satisfy it and we should adhere to the coding standard set in core/phpcs.xml.dist as the "drupal" coding standard from coder actually needs fixing. I have reverted your changes.

  • Pipeline finished with Canceled
    10 months ago
    Total: 289s
    #119933
  • Pipeline finished with Failed
    10 months ago
    Total: 725s
    #119954
  • 🇮🇳India mohit_aghera Rajkot

    Updated branch with latest 11.x head since test case failures were related to 11.x HEAD only.
    Keeping it to RTBC, will check if there are any failures.

  • Pipeline finished with Success
    9 months ago
    Total: 546s
    #120341
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Committed and pushed 18c45f5f23 to 11.x and 462d3ac638 to 10.3.x. Thanks!

    It'd be good to finish up 🐛 Fix label token replacement for views entity reference arguments Fixed and put a more generic fix in place.

    • alexpott committed 462d3ac6 on 10.3.x
      Issue #2765297 by mohit_aghera, joseph.olstad, sylus, ducktape, alexpott...
  • Status changed to Fixed 9 months ago
    • alexpott committed 18c45f5f on 11.x
      Issue #2765297 by mohit_aghera, joseph.olstad, sylus, ducktape, alexpott...
    • catch committed 8ac67595 on 10.3.x
      Revert "Issue #2765297 by mohit_aghera, joseph.olstad, sylus, ducktape,...
    • catch committed 1600f99d on 11.x
      Revert "Issue #2765297 by mohit_aghera, joseph.olstad, sylus, ducktape,...
  • Status changed to Needs work 9 months ago
  • 🇬🇧United Kingdom catch

    This caused the gitlab performance test jobs to fail over the weekend, with:

    Remaining self deprecation notices (2)
      1x: The "Drupal\KernelTests\KernelTestBase::expectDeprecationMessage()" method is considered internal use expectDeprecation() instead. It may change without further notice. You should not extend it from "Drupal\Tests\taxonomy\Kernel\Views\ViewsArgumentDeprecationTest".
        1x in DrupalListener::endTest from Drupal\Tests\Listeners
      1x: The "Drupal\KernelTests\KernelTestBase::expectDeprecationMessageMatches()" method is considered internal use expectDeprecation() instead. It may change without further notice. You should not extend it from "Drupal\Tests\taxonomy\Kernel\Views\ViewsArgumentDeprecationTest".
        1x in DrupalListener::endTest from Drupal\Tests\Listeners
    

    Since ViewsArgumentDeprecationTest appears to be mainly (only?) testing the constructor deprecation, I don't think that was necessary to add in the first place and we could just remove the test, but I didn't review to see if there was a better reason for adding it.

  • 🇮🇳India mohit_aghera Rajkot

    @catch
    I added that initially and my intention was to validate two things.

    1. Validate the deprecation message being displayed
    2. I should be able use and invoke the older plugins with different constructor argument
      $plugin = \Drupal::service('plugin.manager.views.argument')->createInstance('taxonomy_views_argument_test', []);
          $this->assertInstanceOf(TaxonomyViewsArgumentTest::class, $plugin);

    Happy to remove the test case entirely or just expect deprecation only.
    Let me know your thoughts.

  • Status changed to RTBC 9 months ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    @catch @mohit_aghera this test only caused that because it unnecessarily used the trait. Remove the use and this will pass fine as we literally have hundreds of other deprecation tests doing the same thing.

    I think leaving a test in in this case is okay because of the slightly more complicated dance of changing a parameter instead of just adding or removing a parameter.

    Given this is just removing usage of a trait setting back to rtbc.

  • Pipeline finished with Success
    9 months ago
    Total: 506s
    #122310
  • 🇬🇧United Kingdom catch

    Makes sense to me - I can re-commit this a bit later but also think it'd be fine for @alexpott to commit the updated MR here since it's a tiny change.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Committed and pushed 1bcc7f34e6 to 11.x and 46564ee733 to 10.3.x. Thanks!

    Second time lucky.

    • alexpott committed 46564ee7 on 10.3.x
      Issue #2765297 by mohit_aghera, joseph.olstad, sylus, alexpott, ducktape...
  • Status changed to Fixed 9 months ago
    • alexpott committed 1bcc7f34 on 11.x
      Issue #2765297 by mohit_aghera, joseph.olstad, sylus, alexpott, ducktape...
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • 🇬🇧United Kingdom matt b

    This is still an issue. Since upgrading to 10.3 now instead of displaying the untranslated term title, no term title is displayed. It is shown in the english version of the page. Please re-open.

  • 🇳🇱Netherlands Lendude Amsterdam

    @Matt B thanks for reporting this regression. We can't revert this anymore and reopening a long running issue like this will lead to mistakes. I've opened 🐛 [regression] "Content: Has taxonomy term ID (with depth)": instead of displaying the untranslated term title, no term title is displayed Active to address this issue, can you provide a clear description of what broke and some steps to reproduce your issue there? Thanks!

Production build 0.71.5 2024