Problem/Motivation

1. Install Drupal 8 standard. Enable Language, Content translation modules.
2. Configure Articles to be translatable. The tags field on the article should not be translatable (there are confusing things if you make them translatable that do not relate to this issue).
3. However do configure tag terms to be translatable.
4. Add an article with taxonomy terms.
5. Translate those taxonomy terms as their own entities.
6. Translate the article.

Now regardless of which translation of the article you are viewing, the same original language is used to render the terms. Not good.

Proposed resolution

Make the terms show up in the rendering language of the entity.

Remaining tasks

Figure out why, fix, test.

User interface changes

Terms will show up properly localized as expected.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Désiré’s picture

Assigned: Unassigned » Désiré
Gábor Hojtsy’s picture

Issue tags: +Amsterdam2014
Désiré’s picture

Status: Active » Needs review
FileSize
4.79 KB

Test only patch attached.

Désiré’s picture

Here I have a supposed solution, to fix the problem in \Drupal\taxonomy\Plugin\Field\FieldFormatter\TaxonomyFormatterBase but it's not works yet, and Im also not sure if it should be fixed there.

However I attached the patch.

YesCT’s picture

while looking at the test patch in #3 I noticed that ->save was not an available method... cause it is type hinted on the interface (the object has a save(). And @tstoeckler and I found #2175517: Entity displays are themselves config entities which looks like was missing a push. @alimac is going to look into that. (not a problem of this issue).

=======

starting to look at the test only, just a little clean up. (See https://www.drupal.org/node/1354 for some standards things.)

(note #4 is not really test_only. :) )

@Désiré For instructions on creating an interdiff, see https://drupal.org/documentation/git/interdiff | Microbranching workflow: http://xjm.drupalgardens.com/blog/interdiffs-how-make-them-and-why-they-...

The last submitted patch, 3: 2345607-translated_terms_not_rendered-test_only-3.patch, failed testing.

Désiré’s picture

Here is the current, working solution which somehow breaks the test...

The last submitted patch, 4: 2345607-translated_terms_not_rendered-test_only-4.patch, failed testing.

The last submitted patch, 5: 2345607-translated_terms_not_rendered-5.patch, failed testing.

Gábor Hojtsy’s picture

  1. +++ b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/TaxonomyFormatterBase.php
    @@ -24,8 +24,17 @@ public function prepareView(array $entities_items) {
    +      $active_langcode = $items->getParent()->getActiveLangcode();
    

    Is this not supposed to be $item->getLangcode()? That is what the entity_view() code does in entity reference.

  2. +++ b/core/modules/taxonomy/src/Tests/TermTranslationFieldViewTest.php
    @@ -0,0 +1,201 @@
    +  protected $baseLangCode = 'en';
    ...
    +  protected $translateToLangCode = 'hu';
    

    Do not capitalize Lang and Code separately, just Langcode as one.

  3. +++ b/core/modules/taxonomy/src/Tests/TermTranslationFieldViewTest.php
    @@ -0,0 +1,201 @@
    +   * The langcode to have translations into.
    

    Target langcode for translation.

Désiré’s picture

Updates after #10

YesCT’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/TaxonomyFormatterBase.php
    @@ -26,7 +26,7 @@ public function prepareView(array $entities_items) {
    -      $active_langcode = $items->getParent()->getActiveLangcode();
    +      $active_langcode = $items->getParent()->language()->id;
    

    maybe we can do id() or getId().

    working to find what type of thing this is.

  2. +++ b/core/modules/taxonomy/src/Tests/TermTranslationFieldViewTest.php
    @@ -197,5 +197,4 @@ protected function setUpTermReferenceField() {
       }
    -
     }
    

    we should keep this.
    https://www.drupal.org/node/608152

Désiré’s picture

Here is the last version with the fixed test (thank you Gabor), and with some minor improvements after the review with YesCT.

The last submitted patch, 7: 2345607-translated_terms_not_rendered-7.patch, failed testing.

The last submitted patch, 11: 2345607-translated_terms_not_rendered-11.patch, failed testing.

The last submitted patch, 13: 2345607-translated_terms_not_rendered-test_only-13.patch, failed testing.

YesCT’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

I read through the whole patch.
The test is testing what it should, and fails just in the right ways.

removing the needs tests tag.

The fix makes sense.

This looks ready to go to me.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

  • webchick committed 5d730a0 on 8.0.x
    Issue #2345607 by YesCT, Désiré | Gábor Hojtsy: Fixed Translated...
webflo’s picture

tim.plunkett’s picture

Title: Translated taxonomy terms not rendered in the entity display language » HEAD BROKEN: Translated taxonomy terms not rendered in the entity display language
Status: Fixed » Needs review
Gábor Hojtsy’s picture

Title: HEAD BROKEN: Translated taxonomy terms not rendered in the entity display language » Translated taxonomy terms not rendered in the entity display language
Status: Needs review » Fixed

Committed. Thanks! Its unfortunate #2344821: Unify 'name' / 'field_name' in FieldConfig / FieldStorageConfig did not get retested (in time) and the combination of the two committed broke.

  • Gábor Hojtsy committed ca513fb on 8.0.x
    Issue #2345607 followup by webflo: The combination of #2345607 and #...

Status: Fixed » Needs work

The last submitted patch, 20: 2345607-fix-head.patch, failed testing.

swentel’s picture

Status: Needs work » Fixed

Slow testbot :)

Status: Fixed » Closed (fixed)

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