Skip to content

04 · Formatted text props ({value, format}) of components are not marked translatable

Project Canvas
Component Translation
Category Bug report
Priority Normal
Status Reported upstream as #3592153

Problem/Motivation

Props that hold formatted text are stored as {value: '<p>…</p>', format: canvas_html_block}. In the config schema generated for a component instance, they get type: ignore without translatable: true, while simple string props next to them are translatable. As a result, formatted text (e.g. body of Morphos' card_canvas, intro of section) cannot be translated in the Canvas translation UI.

Side finding: readmore_url (a URL) is marked translatable, although it is not prose.

Determined with JsonSchemaPropsComponentInstanceInputsConfigSchemaGenerator::refineForInstance().

Steps to reproduce

  1. Install Drupal CMS with Convivial Gov (Morphos theme).
  2. Inspect the generated config schema for a card_canvas instance: body has type: ignore and no translatable key.
  3. Try to translate the card body in the translation UI – it is not offered.

Proposed resolution

Mark formatted text props (contentMediaType: text/html, or props stored as {value, format}) as translatable; mark URL props as not translatable.

Remaining tasks

Patch + test.

Additional information

Workaround in dcle (CanvasComponentTreeTranslator::getTranslatableProps()). Related: markup string props, see the separate issue about x-formatting-context.

Copy to drupal.org

Issue title:

Formatted text props ({value, format}) of components are not marked translatable

Issue summary (paste it into the "Issue summary" field; project, component, category and priority are in the table above):

<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Props that hold formatted text are stored as <code>{value: '<p>…</p>', format: canvas_html_block}</code>. In the config schema generated for a component instance, they get <code>type: ignore</code> without <code>translatable: true</code>, while simple string props next to them are translatable. As a result, formatted text (e.g. <code>body</code> of Morphos' <code>card_canvas</code>, <code>intro</code> of <code>section</code>) cannot be translated in the Canvas translation UI.</p>
<p>Side finding: <code>readmore_url</code> (a URL) is marked translatable, although it is not prose.</p>
<p>Determined with <code>JsonSchemaPropsComponentInstanceInputsConfigSchemaGenerator::refineForInstance()</code>.</p>
<h3 id="summary-steps-reproduce">Steps to reproduce</h3>
<ol>
<li>Install Drupal CMS with Convivial Gov (Morphos theme).</li>
<li>Inspect the generated config schema for a <code>card_canvas</code> instance: <code>body</code> has <code>type: ignore</code> and no <code>translatable</code> key.</li>
<li>Try to translate the card body in the translation UI – it is not offered.</li>
</ol>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Mark formatted text props (<code>contentMediaType: text/html</code>, or props stored as <code>{value, format}</code>) as translatable; mark URL props as not translatable.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>Patch + test.</p>
<h3>Additional information</h3>
<p>Workaround in <code>dcle</code> (<code>CanvasComponentTreeTranslator::getTranslatableProps()</code>). Related: markup string props, see the separate issue about <code>x-formatting-context</code>.</p>