Add TMGMT translation integration for content entities
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3590948. --> Reported by: [tedbow](https://www.drupal.org/user/240860) >>> <h3 id="overview">Overview</h3> <p>When using TMGMT (Translation Management Tool) to translate Canvas content entities (nodes, etc.) with component_tree fields, each component instance's translatable props should appear as separate translatable strings in the TMGMT review UI. Without a custom field processor, the component_tree field is treated as an opaque blob.</p> <p>Note: TMGMT integration for Canvas <em>config entities</em> (canvas_page, etc.) is tracked separately in <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3582558" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3582558</a></span>.</p> <p>A <code>ComponentTreeFieldProcessor</code> was developed on the <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3583684" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3583684</a></span> (symmetric content inputs) branch but removed as a separate concern to land independently.</p>. See this commit where it was removed to get the latest work from the issue https://git.drupalcode.org/project/canvas/-/merge_requests/882/diffs?commit_id=3d08e0ef3cbce077ec542c573b461d07270bb552 <h3 id="proposed-resolution">Proposed resolution</h3> <p>Add <code>src/Tmgmt/ComponentTreeFieldProcessor.php</code> which extends <code>LinkFieldProcessor</code> from <code>tmgmt_content</code> and:</p> <ul> <li><code>extractTranslatableData()</code>: exposes each translatable prop of each component instance as a separate translatable string, grouped by component UUID, in the TMGMT review form</li> <li><code>setTranslations()</code>: applies TMGMT translations back to component inputs</li> <li><code>rewrapForParentSetTranslations()</code>: helper to reformat collapsed prop data for parent class expectations</li> </ul> <p>Register it in <code>ShapeMatchingHooks::fieldInfoAlter()</code> when <code>tmgmt_content</code> is installed:</p> <pre><pre>if (isset($info['component_tree']) &amp;&amp; $this-&gt;moduleHandler-&gt;moduleExists('tmgmt_content')) {<br>&nbsp; $info['component_tree']['tmgmt_field_processor'] = ComponentTreeFieldProcessor::class;<br>}</pre></pre><p>Add test coverage in <code>TranslationTest::testTmgmtComponentTreeFieldProcessor()</code> verifying the TMGMT review UI shows translatable prop values and that accepted translations are applied correctly.</p> <h3 id="ui-changes">User interface changes</h3> <p>Translatable component props appear as separate strings in the TMGMT translation review form instead of a single opaque field blob.</p> > Related issue: [Issue #3583684](https://www.drupal.org/node/3583684) > Related issue: [Issue #3582558](https://www.drupal.org/node/3582558) > Related issue: [Issue #3590196](https://www.drupal.org/node/3590196)
issue