Embed paragraphs cannot be translated

Created on 28 June 2022, about 3 years ago
Updated 5 May 2025, 3 months ago

Problem/Motivation

It is not possible to translate paragraph from within the entity form displayed in the entity browser.

Any changes made in this form is made on the original paragraph, not a translation.

Steps to reproduce

Install this module. Add language. Embed a paragraph. Translate the parent entity.

Result: the embed paragraph cannot be translated.

Proposed resolution

TBD

Remaining tasks

TBD

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • miiimooo Europe

    @matthieuscarset this is possible, if the paragraph type is correctly configured - see https://www.drupal.org/docs/contributed-modules/paragraphs/multilingual-...

    I have found a problem more recently, where the translation gets created correctly when using this combination of paragraphs, paragraphs_inline_entity_form, entity_embed and embed, but any subsequent edits lead to an ajax error:

    Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.paragraph.content_translation_delete" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 211 of core/lib/Drupal/Core/Routing/RouteProvider.php).
    Drupal\Core\Routing\UrlGenerator->getRoute('entity.paragraph.content_translation_delete') (Line: 276)
    Drupal\Core\Routing\UrlGenerator->generateFromRoute('entity.paragraph.content_translation_delete', Array, Array, 1) (Line: 108)
    Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('entity.paragraph.content_translation_delete', Array, Array, 1) (Line: 765)
    Drupal\Core\Url->toString(1) (Line: 183)
    Drupal\Core\Utility\LinkGenerator->generate(Object, Object) (Line: 102)
    Drupal\Core\Render\Element\Link::preRenderLink(Array)
    call_user_func_array(Array, Array) (Line: 113)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725 ', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 875)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 432)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
    Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array, 1) (Line: 153)
    Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 152)
    Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 36)
    Drupal\Core\Ajax\OpenDialogCommand->getRenderedContent() (Line: 148)
    Drupal\Core\Ajax\OpenDialogCommand->render() (Line: 43)
    Drupal\Core\Ajax\AjaxResponse->addCommand(Object) (Line: 109)
    Drupal\entity_browser\Controllers\EntityBrowserController->entityBrowserEdit(Object, 'default', Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 53)
    Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

  • miiimooo Europe

    This is a workaround, since there is no route in the patch in #2721665-69: Problems with multilingual entities to delete a paragraph translation; it's only supported in the parent entity. The easiest fix is to remove the "Delete translation" button. Not ideal, it would be better to handle the translation routes or add the link templates in the paragraph module so the ContentTranslationRouteSubscriber can add the routes.

    /**
     * Implements hook_form_BASE_FORM_ID_alter().
     */
    function MY_MODULE_form_paragraph_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
      if (!$form_state->getFormObject() instanceof \Drupal\Core\Entity\EntityFormInterface) {
        return;
      }
      $entity = $form_state->getFormObject()->getEntity();
      if (!$entity || !$entity->isTranslatable()) {
        return;
      }
      $form['actions']['#after_build'][] = '_MY_MODULE_paragraph_translatable_form_after_build';
    }
    
    /* Callback for #after_build to remove delete translation link using missing Route */
    function _MY_MODULE_paragraph_translatable_form_after_build($element, FormStateInterface $form_state) {
      if (isset($element['delete_translation'])
          && $element['delete_translation']['#url']->getRouteName() == 'entity.paragraph.content_translation_delete') {
        unset($element['delete_translation']);
      }
      return $element;
    }
    
Production build 0.71.5 2024