Anmol Goel commented on issue #3544189 at project / ai

Anmol Goel
2026-04-23T01:02:00Z

Migrated from comment #7 posted 02 Sep 2025 at 17:38 UTC

- Status: Needs review
+ Status: Needs work

The same solution also needs to be applied in ReferenceFieldExtractor.php and AiTranslateCommands.php.

--- a/modules/ai_translate/src/Plugin/FieldTextExtractor/ReferenceFieldExtractor.php
+++ b/modules/ai_translate/src/Plugin/FieldTextExtractor/ReferenceFieldExtractor.php
@@ -184,7 +184,7 @@ class ReferenceFieldExtractor extends FieldExtractorBase implements Configurable

// Check if the entity has the translation, create it if not.
if (!$entity->hasTranslation($language)) {
-      $translatedEntity = $entity->addTranslation($language);
+      $translatedEntity = $entity->addTranslation($language, $entity->toArray());
}
else {
$translatedEntity = $entity->getTranslation($language);

--- a/modules/ai_translate/src/Drush/AiTranslateCommands.php
+++ b/modules/ai_translate/src/Drush/AiTranslateCommands.php
@@ -119,7 +119,7 @@ class AiTranslateCommands extends DrushCommands {
$translated_text_item = html_entity_decode($translated_text_item);
}
}
-    $translation = $entity->addTranslation($langTo);
+    $translation = $entity->addTranslation($langTo, $entity->toArray());
$this->textExtractor->insertTextMetadata($translation,
$textMetadata);
try {