AI Translate: LbFieldExtractor adds translations with default values for empty fields.
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3544189. -->
Reported by: [anmolgoyal74](https://www.drupal.org/user/3560428)
Related to !858
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>AI Translate: LbFieldExtractor adds translations with field's default values if these fields are empty in the original block entity. </p>
<h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4>
<p>Please provide information like AI modules enabled, which AI provider, browser, etc.<br>
Let's say we have a block component having multiple fields. In the field settings we have set some default values for these fields, but these fields are not required.<br>
So when we add the block and keep any field blank and also remove the default values and saves it, and then we add generate the AI translations, The fields which are empty empty are now filled with field's default values in the translated version. </p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Change the code from </p>
<pre> $blockEntity = $blockEntity->hasTranslation($translationLanguage)<br> ? $blockEntity->getTranslation($translationLanguage)<br> : $blockEntity->addTranslation($translationLanguage);</pre><p>
to </p>
<pre> <br> $blockEntity = $blockEntity->hasTranslation($translationLanguage)<br> ? $blockEntity->getTranslation($translationLanguage)<br> : $blockEntity->addTranslation($translationLanguage, $blockEntity->toArray());</pre><h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3>Optional: Other details as applicable (e.g., User interface changes, API changes, Data model changes)</h3>
issue