Hardcoded 'By' string in hero-blog.twig prevents UI translation
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3580684. --> Reported by: [joachim namyslo](https://www.drupal.org/user/275771) Related to !28 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>In the <code>hero-blog.twig</code> component, the "By" prefix which is displayed before the author name is hardcoded. This prevents the string from being translated on multilingual Drupal sites using the User Interface Translation feature.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>1. Install and enable the Byte Theme.<br> 2. Enable the core <code>locale</code> module and add a secondary language (e.g., German).<br> 3. Create a content item that uses the <code>hero-blog</code> component and has an author assigned.<br> 4. Go to the User Interface Translation page (<code>/admin/config/regional/translate</code>) and search for the string "By".<br> 5. Notice that the string is not available for translation, and therefore the English "By" is shown on translated frontend pages.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Wrap the hardcoded string with Drupal's Twig <code>trans</code> tag.</p> <p>In <code>components/hero-blog/hero-blog.twig</code>, wrap:</p> <p><code>By {{ author }}</code></p> <pre>&nbsp;&nbsp;&nbsp; {% trans %}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; By {{ author }}<br>&nbsp;&nbsp;&nbsp; {% endtrans %}</pre><h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>- Review and commit.</p> <h3 id="summary-ui-changes">User interface changes</h3> <p>The "By @author" string will now be available for translation in the User Interface Translation at <code>/admin/config/regional/translate</code>.</p> <h3 id="summary-api-changes">API changes</h3> <p>None.</p> <h3 id="summary-data-model-changes">Data model changes</h3> <p>None.</p>
issue