- Issue created by @anmolgoyal74
- ๐ง๐ฌBulgaria valthebald Sofia
@anmolgoyal74: that's a good proposal! Do you want to create a merge request, or someone else can?
- ๐ฎ๐ณIndia Ishani Patel
ishani patel โ made their first commit to this issueโs fork.
- Merge request !858Issue #3544189: AI Translate: LbFieldExtractor adds translations with default... โ (Merged) created by Unnamed author
- ๐ฎ๐ณIndia Ishani Patel
Hello,
I've created a Merge request.
Please check and review.Thank you!
- ๐ฎ๐ณIndia anmolgoyal74
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 {
- ๐ง๐ชBelgium svendecabooter Gent
anmolgoyal74: can you add this to the MR?
The change in modules/ai_translate/src/Plugin/FieldTextExtractor/ReferenceFieldExtractor.php did fix the issue I encountered on a website, where untranslated fields (eg regular select list) where left blank in the AI translation.
- ๐ฎ๐ณIndia anmolgoyal74
Applied the changes to ReferenceFieldExtractor.php and AiTranslateCommands.php..