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.
Issue fork estimated_read_time-3395919
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
Comment #3
simonbaeseComment #6
mtalt commentedComment #7
mtalt commentedThank 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.