Problem/Motivation

In #2954151: Allow users to change replicated entity's label before confirming we have added the suffix " (Copy)" to the default value of the replicated entity's title.

However, if the entity has translations, the suffix is not added to the label of the translations.

It would be important to have the suffix there too.

Proposed resolution

On the confirmation page, add one form element per available translation, with the translated suffix. This way users can customize the suffix on each label, if necessary.

Remaining tasks

User interface changes

Before:

After:

API changes

Data model changes

Comments

marcoscano created an issue. See original summary.

marcoscano’s picture

Assigned: marcoscano » Unassigned
Status: Active » Needs review
StatusFileSize
new4.1 KB

Missing test coverage, but it should be enough to validate the approach.

Status: Needs review » Needs work

The last submitted patch, 2: 2972955-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

berdir’s picture

  1. +++ b/src/Form/ReplicateConfirmForm.php
    @@ -56,16 +57,39 @@ class ReplicateConfirmForm extends ContentEntityConfirmFormBase {
    +          /** @var \Drupal\Core\Entity\TranslatableInterface $translation */
    +          $translation = $entity->getTranslation($langcode);
    +          if ($entity->hasTranslation($langcode)) {
    +            $form['new_label_' . $langcode] = [
    

    the hasTranslation() call is not necessary, you loop over getTranslationLanguages(), which is only the existing translations.

    Beside, you call getTranslation() above, so it would fail on that anyway :)

  2. +++ b/src/Form/ReplicateConfirmForm.php
    @@ -56,16 +57,39 @@ class ReplicateConfirmForm extends ContentEntityConfirmFormBase {
    +              '#title' => $this->t('New label (@language)', ['@language' => $translation_language->getName()]),
    +              '#description' => $this->t('This text will be used as the label of the new entity being created.'),
    

    maybe update the description too?

Can you include a screenshot as well? But I think this direction makes sense.

marcoscano’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new9.64 KB
new7.94 KB
new20.57 KB
new29.55 KB

@Berdir thanks for reviewing!

I've added some screenshots to the IS.

Status: Needs review » Needs work

The last submitted patch, 5: 2972955-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

marcoscano’s picture

Status: Needs work » Needs review
StatusFileSize
new10.11 KB
new1.45 KB

  • Berdir committed d56b27f on 8.x-1.x authored by marcoscano
    Issue #2972955 by marcoscano: Add "(Copy)" title suffix to translations...
berdir’s picture

Status: Needs review » Fixed

Thanks.

Status: Fixed » Closed (fixed)

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