Problem/Motivation

The estimated read time is calculated on presave of the entity. The estimation is only done for the current translation. Especially, when creating entities programmatically, one may want to create multiple translations at once. Then also the read time for other translations should be processed.

Steps to reproduce

See the failing test in #3351967: Add kernel tests.

1. Create a node with a specified language.
2. Add a translation.
3. Save node.
4. The read time is only calculated for the specified language and not the translation.

Proposed resolution

In the presave check whether the entity implements the TranslatableInterface and if translations have changes by $translation->hasTranslationChanges(). Then estimate the read time for the translations.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

simonbaese created an issue. See original summary.

simonbaese’s picture

Status: Active » Needs review

mtalt made their first commit to this issue’s fork.

  • mtalt committed 44819903 on 1.0.x authored by simonbaese
    Issue #3395919: Estimate read time for multi-language entity saves
    
mtalt’s picture

Status: Needs review » Fixed
mtalt’s picture

Thank you @simonbaese. I tested programmatically creating a translation and replicated the issue. Your changes resulted in the estimated read time being calculated on the translation.

Status: Fixed » Closed (fixed)

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