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> heading:<br> type: string<br> title: Heading<br> description: The main heading of the hero<br> examples:<br> - There goes my hero<br> - Submit now<br> subheading:<br> type: string<br> title: Sub-heading<br> description: 'See the <a href="https://www.example.com/icons">icon library</a> for icons.'<br> examples:<br> - Watch him as he goes!<br> cta1:<br> type: string<br> title: CTA 1 text<br> examples:<br> - View<br> # ℹ️ For an example of a CTA that supports only absolute URLs, see the my-cta SDC.<br> cta1href:<br> type: string<br> format: uri-reference<br> title: CTA 1 link<br> examples:<br> - https://example.com<br> - /node/1<br> cta2:<br> type: string<br> title: CTA 2 text<br> examples:<br> - Click<br> # @see \Drupal\Core\Template\ComponentsTwigExtension::mergeAdditionalRenderContext()<br> attributes:<br> type: Drupal\Core\Template\Attribute<br> name: Attributes<br> 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> inputs:<br> type: mapping<br> class: '\Drupal\canvas\Config\Schema\ComponentSpecificInputs'<br> 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