Overview

Canvas is aiming to first bring symmetrical translation, which we believe serves the majority best.

This issue is about ensuring that we make asymmetrical translations a future possibility. And for gathering relevant information.

Reference: how it works for content-defined component trees

For content entities, \Drupal\content_translation\FieldTranslationSynchronizer(Interface) provides the infrastructure to do symmetric or asymmetric translation. Thanks to that, all Canvas needs in ComponentTreeItem is this:

  // @see docs/data-model.md
  // @see \Drupal\content_translation\Hook\ContentTranslationHooks::fieldInfoAlter()
  column_groups: [
    'inputs' => [
      'label' => new TranslatableMarkup('Component input values'),
      'translatable' => TRUE,
      'columns' => [
        'inputs',
        // Even when keeping the same component tree, content authors should
        // be able to specify a translated label to provide context.
        'label',
      ],
    ],
    'tree' => [
      'label' => new TranslatableMarkup('Component tree'),
      'translatable' => TRUE,
      // If the tree is translated, then the inputs also need to be.
      'require_all_groups_for_translation' => TRUE,
      'columns' => [
        'parent_uuid',
        'slot',
        'uuid',
        'component_id',
        'component_version',
      ],
    ],
  ],

👆 This means that for Canvas fields on content entities, the decision for symmetric vs asymmetric translation is made at the field definition level — that means either the base field (e.g. Canvas' Page content entity type) or a bundle field (e.g. a Canvas field added to a Node bundle — which is currently disabled to avoid confusion with Content Templates until we build Exposed Slots, but we know it works).

Versus config-defined component trees

For config entities, there's no easy way to switch between the two modes. One site may want Canvas' page regions asymmetrically translatable, but Canvas' content templates symmetrically. Another might want the opposite.

Proposed resolution

Either:

Granular
Allow each config entity type with a component tree to decide on (a)symmetric translatability itself. The content template for "article" could be symmetrically translated, but that for "product" not.
Coarse
Configure site-wide whether all content templates are (a)symmetrically translated. Same for all page regions. Et cetera.

User interface changes

TBD

Comments

wim leers created an issue. See original summary.

wim leers’s picture

Title: [later phase] Support asymmetric translation of config-defined component trees: » [later phase] Support asymmetric translation of config-defined component trees
Assigned: Unassigned » lauriii
Priority: Normal » Major
Issue summary: View changes
Status: Active » Postponed
Issue tags: +Needs product manager review
StatusFileSize
new3.84 KB

Outline of how the granular approach can work, on top of !868.

✅!868's \Drupal\Tests\canvas\Kernel\Config\ContentTemplateTest::testTranslationLifeCycleInDepth() passes with this patch applied.

wim leers’s picture

This achieves the same as #3571232's \Drupal\canvas_dev_translation\Hook\MakeComponentTreeTranslatable::configSchemaInfoAlter() on a per-config entity basis — meaning the user has the choice, instead of no choice.