Problem/Motivation

Comment tokens always consider the original submission language of a comment and do not take the translated value. Additionally to that, the comment body field is optional and may not be present.

Proposed resolution

1. Load the translated comment appropriate for the token's context.
2. Only attempt to use the comment body field if its present.

Remaining tasks

Postponed on #2529182: Not all node, taxonomy entity tokens are multilingual aware
Add tests.

User interface changes

None.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

Status: Active » Postponed
Issue tags: +Entity Field API
YesCT’s picture

Issue tags: +D8MI

d8mi might want to track this.

fago’s picture

Status: Postponed » Active
andypost’s picture

Issue summary: View changes
Issue tags: +Needs issue summary update

No idea what's left here

andypost’s picture

Status: Active » Postponed (maintainer needs more info)
andypost’s picture

@plach said that the issue need to check that proper translation object is passed to "token replace"

@fago please drop a light

andypost’s picture

Status: Postponed (maintainer needs more info) » Active

A kind of that used in node.tokens.inc

          $translation = \Drupal::entityManager()->getTranslationFromContext($node, $langcode, array('operation' => 'node_tokens'));
andypost’s picture

Status: Active » Needs review
FileSize
904 bytes
jibran’s picture

Issue tags: +Needs tests

Can we add some tests for this?

larowlan’s picture

looks good but agree on tests

plach’s picture

+++ b/core/modules/comment/comment.tokens.inc
@@ -146,7 +146,10 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
+          $translation = \Drupal::entityManager()->getTranslationFromContext($comment, $langcode, array('operation' => 'comment_tokens'));

Can we get the translation object outside of the switch statement? This way all translatable fields will behave correctly.

YesCT’s picture

Issue summary: View changes
Status: Needs review » Needs work
Parent issue: » #1778178: Convert comments to the new Entity Field API
andypost’s picture

Status: Needs work » Needs review
FileSize
1.39 KB
1.27 KB

Suppose that should be like that?

larowlan’s picture

+++ b/core/modules/comment/comment.tokens.inc
@@ -150,7 +151,10 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
+          // @todo Rename token to comment_body to prevent collisions with contrib.

>80 and I think a new issue to link to would be great

andypost’s picture

FileSize
738 bytes
1.26 KB
Gábor Hojtsy’s picture

Patch looks good. Still needs tests :)

jibran’s picture

Title: Comment tokens should use EntityNG translation API » Comment tokens should use entity translation API

EntityNG is here now.

penyaskito’s picture

Status: Needs review » Needs work

Needs work for the tests.

Gábor Hojtsy’s picture

Issue tags: -sprint

Nobody is working on tests, so removing from the sprint :(

Status: Needs work » Needs review

andypost’s picture

Issue tags: +sprint
FileSize
1.48 KB

Re-roll patch, working on tests

andypost’s picture

Looks better to wait for #2529182: Not all node, taxonomy entity tokens are multilingual aware
Because it introduced useful trait for testing tokens and metadata

Gábor Hojtsy’s picture

Issue tags: -sprint

Removing from sprint so it reflects what is currently being worked on.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

TR’s picture

Version: 8.6.x-dev » 8.8.x-dev
FileSize
1.49 KB

Updated patch #22 to current HEAD - removed deprecated \Drupal::entityManager()

Still needs tests.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). 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: 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.

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.

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.

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.

smustgrave’s picture

Status: Needs review » Needs work

For the tests.

quietone’s picture

Issue summary: View changes
Status: Needs work » Postponed
Issue tags: +Bug Smash Initiative

This was a bugsmash triage target a few days ago. mstrlen suggested either postponing this on the traits being introduced in #2529182: Not all node, taxonomy entity tokens are multilingual aware or splitting the creation of the traits to a new issue. Since the traits are already in the patch of the other issue I am choosing the first option, postponing.

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.