Up to 1.3.1 the translation workflow - resolve the source translation, extract text metadata, translate each field, save - was written out twice: in AiTranslateController as batch operations, and in AiTranslateCommands as a synchronous loop. A module that wanted to run it had to write a third copy.
1.4.0 moves it into ai_translate.translation_orchestrator. The Translate tab and the Drush commands are now thin callers, and so are two new ones that ship with the module. Nothing changes for site builders.
Translating an entity
One call, and an EntityTranslationResult back:
$result = $orchestrator->translateEntity($entity, 'en', 'nl'); $result->isSuccess(); // translation created and saved $result->translationExists(); // entity already had that translation $result->getTranslatedEntity(); // ContentEntityInterface|NULL $result->getFailures(); // names of fields that failed $result->getMessage(); // string|TranslatableMarkup
A field that fails to translate is skipped and reported in getFailures(); the rest of the entity is still saved.
The service
Drupal\ai_translate\EntityTranslationOrchestratorInterface:
translateEntity($entity, $langFrom, $langTo): end to end, returns anEntityTranslationResult.resolveSourceEntity(),extractTextMetadata(),translateTextMetadataItem(),saveTranslatedEntity(): the individual steps, for callers that need to interleave work between them. The Translate tab uses these to spread the fields over a batch.
New callers
ai_translate:translate_entity: AI function call pluginai_translate_tool:translate_entity: Tool API plugin in the new optionalai_translate_toolsubmodule, which depends on Tool.