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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3583945-granularly-asymetrically-translated-config-defined-component-trees.patch | 3.84 KB | wim leers |
Comments
Comment #2
wim leersOutline 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.Comment #3
wim leersThis 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.