IN #2538514-13: Remove argument support from Translation Annotation @dawehner pointed out that we need to be using TranslationWrapper objects in derivative definitions. At the moment we use t() in ViewsEntityRow::getDerivativeDefinitions()

CommentFileSizeAuthor
#3 2539110.1.patch24 KBalexpott

Comments

alexpott’s picture

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new24 KB

This is going to be hard.

There are things I don't know how to fix. BlockConent::getDerivativeDefinitions() for example.

  public function getDerivativeDefinitions($base_plugin_definition) {
    $block_contents = $this->blockContentStorage->loadMultiple();
    /** @var $block_content \Drupal\block_content\Entity\BlockContent */
    foreach ($block_contents as $block_content) {
      $this->derivatives[$block_content->uuid()] = $base_plugin_definition;
      // @todo what to do about this?
      $this->derivatives[$block_content->uuid()]['admin_label'] = $block_content->label();
      $this->derivatives[$block_content->uuid()]['config_dependencies']['content'] = array(
        $block_content->getConfigDependencyName()
      );
    }
    return parent::getDerivativeDefinitions($base_plugin_definition);
  }

This means that in the block admin ui it won't use a french content block title for the admin label if english has been viewed first - because the admin_label is cached in the plugin definition.

I've tried to highlight where I think we have difficulties with @todo's.

dawehner’s picture

Mhh tricky is real life.

  1. +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php
    @@ -90,6 +90,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
    +            // @todo not sure
                 'label' => $bundle_info['label'],
    

    mhhh tricky one ... given that bundles are coming from config entities .. in order words this is an examples where the information is better cached per langcode

  2. +++ b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php
    @@ -52,6 +52,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
    +      // @todo what to do about this?
           $this->derivatives[$block_content->uuid()]['admin_label'] = $block_content->label();
    

    so this would be content entity translated, mhhh

  3. +++ b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php
    @@ -145,6 +146,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
    +            // @todo what to do?
                 'title' => $form_mode_info['label'],
    

    Form mode is again coming from a config entity

Status: Needs review » Needs work

The last submitted patch, 3: 2539110.1.patch, failed testing.

Status: Needs work » Needs review

catch queued 3: 2539110.1.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 3: 2539110.1.patch, failed testing.

xano’s picture

in order words this is an examples where the information is better cached per langcode

#2633878: Finalize cacheability for plugins supports this.

berdir’s picture

This might be a won't fix/duplicate now?

t() always returns a translation wrapper, nothing is translated until it's actually printed now.

xano’s picture

Status: Needs work » Closed (won't fix)

Ah, of course :)