Symmetric translations for content entities should allow only translatable properties in inputs to be overridden
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3583684. --> Reported by: [tedbow](https://www.drupal.org/user/240860) Related to !882 >>> <h3 id="overview">Overview</h3> <p>For symmetric translations it should be possible for a content entity translation to only store the string translatable inputs and rely on the default language translation for other inputs</p> <p>for instance looking at <code>tests/modules/canvas_test_sdc/components/my-hero/my-hero.component.yml</code></p> <pre>&nbsp;&nbsp;&nbsp; heading:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type: string<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title: Heading<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; description: The main heading of the hero<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; examples:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - There goes my hero<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Submit now<br>&nbsp;&nbsp;&nbsp; subheading:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type: string<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title: Sub-heading<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; description: 'See the &lt;a href="https://www.example.com/icons"&gt;icon library&lt;/a&gt; for icons.'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; examples:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Watch him as he goes!<br>&nbsp;&nbsp;&nbsp; cta1:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type: string<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title: CTA 1 text<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; examples:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - View<br>&nbsp;&nbsp;&nbsp; # &#8505;&#65039; For an example of a CTA that supports only absolute URLs, see the my-cta SDC.<br>&nbsp;&nbsp;&nbsp; cta1href:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type: string<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; format: uri-reference<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title: CTA 1 link<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; examples:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - https://example.com<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - /node/1<br>&nbsp;&nbsp;&nbsp; cta2:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type: string<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title: CTA 2 text<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; examples:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Click<br>&nbsp;&nbsp;&nbsp; # @see \Drupal\Core\Template\ComponentsTwigExtension::mergeAdditionalRenderContext()<br>&nbsp;&nbsp;&nbsp; attributes:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type: Drupal\Core\Template\Attribute<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name: Attributes<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title: Attributes</pre><p> The <code>cta1href</code> and <code>attributes</code> properties should not be translatable.</p> <p>But if you don't store the <code>cta1href</code> property with the translation you will get the error like</p> <blockquote><p> LogicException: inputs.208452de-10d6-4fb8-89a1-10e340b3744c.cta1href: The property cta1href is required. </p></blockquote> <p>and </p> <blockquote><p> Drupal\Core\Entity\EntityStorageException: inputs.208452de-10d6-4fb8-89a1-10e340b3744c.cta1href: The property cta1href is required. </p></blockquote> <p><span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3582478" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3582478</a></span> deals with similar problem but for config entities that implement \Drupal\canvas\Entity\ComponentTreeConfigEntityBase</p> <p>There are other problems with making these properties separate elements in forms provided by <code>content_translation</code> and <code>tmgmt_content</code> but this issue only deals with storage and programmatically saving</p> <h3 id="proposed-resolution">Proposed resolution</h3> <p>As start update <code>\Drupal\Tests\canvas\Functional\TranslationTest::createCanvasNodeWithTranslation</code> to unset <code>cta1href</code> and <code>attributes</code> in the translation. This will result in the errors above.</p> <p>Figure out how to solve this. Probably this will mean updating validators and maybe <code>\Drupal\canvas\Plugin\Field\FieldType\ComponentTreeItem</code>, maybe getInputs and getInput</p> <p>It probably makes sense to look at how <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3582478" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3582478</a></span> is solving this for config. </p> <p>Specifically in config/schema/canvas.schema.yml it has </p> <pre>&nbsp;&nbsp;&nbsp; inputs:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type: mapping<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class: '\Drupal\canvas\Config\Schema\ComponentSpecificInputs'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; label: 'Input values for each component in the component tree'</pre><p> ComponentSpecificInputs looks at the component source inputs to determine which ones are translatable. Eventually we will probably want to API to get the translatable properties for a component source but for now we can probably copy some of that logic.</p> <h3 id="ui-changes">User interface changes</h3> > Related issue: [Issue #3582478](https://www.drupal.org/node/3582478) > Related issue: [Issue #3520449](https://www.drupal.org/node/3520449) > Related issue: [Issue #3586342](https://www.drupal.org/node/3586342) > Related issue: [Issue #3590196](https://www.drupal.org/node/3590196)
issue