Generated with the help of an LLM.

Problem/Motivation

Cloning a translatable entity copies only one translation. The other translations of the original are lost and have to be added again by hand.

Steps to reproduce

  1. Make a content type translatable and enable cloning for it.
  2. Create a node in English and translate it.
  3. Clone the English node and save the clone.
  4. The clone has only the English translation.

Proposed resolution

Add an opt-in "Copy all translations" setting per bundle. When it is on, the clone gets every translation of the original that the user can update, using the configured field processors.

Remaining tasks

Review the MR.

User interface changes

New checkbox on the bundle settings form, off by default.

API changes

None.

Data model changes

New boolean key copy_translations in the bundle settings config.

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

boychev created an issue. See original summary.

boychev’s picture

Status: Active » Needs review

I opened !18 with the same change for 2.x, the default branch. There the code goes into ContentEntityCloneHooks::entityPrepareForm(). The setting, the form and the README text are the same as in !17, which stays for 1.1.x. CopyTranslationsTest is the same apart from the 2.x conventions (the CloneQueryParameter enum for the query keys, and no @group annotation).

The kernel tests pass, locally on Drupal 11.4.13 and in the MR pipeline, and three of the four new tests fail without the hook change. The red jobs come from 2.x itself, not from this change:

  • phpunit: on Drupal 11.4.0 with twig 3.28, CloneNodeFunctionalTest gets a 500 on the node page, from a TypeError in core's field--node--title.html.twig.
  • phpstan: a newer phpstan-drupal rule flags the existing entityOperation() hook, which lacks the CacheableMetadata parameter added in Drupal 11.3.
  • phpunit (next minor): every test passes, but deprecations end each run with exit code 1.

2.x has had no pipeline since July, so I could not compare it there.

Setting this to Needs review.

AI-assisted: Claude Code ported the change, ran the tests, read the CI logs and drafted this comment. I reviewed it.