Translation Queue
The translation queue is a Symfony messenger queue which is responsible for processing translation entries.
Configuration
Cronjob
*/5 * * * * php bin/console messenger:consume twocream_deepl_translation --time-limit 300
Structure of the queue message
Class
Twocream\DeepLBundle\MessageQueue\Message\ElementTranslationMessage
Description
| Name | Value |
|---|---|
| Constructor | public function __construct(int $elementId, string $elementType, string $pimcoreSourceLanguage, ?array $pimcoreTargetLanguages = null, ?TranslationContextInterface $translationContext = null, bool $skipExistingTranslation = false, bool $allowInheritedValues = false,bool $doPublishVersion = true) |
$elementId | ID of the element (object, asset, ...) |
$elementType | Type of the element (object, asset, ...) |
$pimcoreSourceLanguage | The source language (de, en, ...) |
| Optional | |
$pimcoreTargetLanguages | A collection of target languages with the following structure: ['de', 'en', 'fr'] |
$translationContext | The Translation context contains all information, this differs depending on the element type (metadata fields, relation fields, glossaries, ....). |
$skipExistingTranslation | Decides whether or not to overwrite existing field contents. |
$allowInheritedValues | Decides whether or not to account for the fallbacks of languages (e.g. in a localized field) as well as for the element inheritence. If so, they are stored locally on the element. |
$doPublishVersion | Decides whether the first translated version is published or only saved as a version. |
Usage
Creation of new translation entries
A translation entry is required to translate an element (e.g. an object). Such entries can be created flexibly, including several optional parameters.
info
Below is an example of parameter assignment, it is however only for illustration purposes and not strictly required.
<?php
$glossaries = [
'de' => [
'en' => 'GLOSSAR_ID'
]
];
$objectTranslationContext = new ObjectTranslationContextDto(glossaries: $glossaries);
$elementTranslationMessage = new ElementTranslationMessage(
$element->getId(),
$element->getType(),
'de',
pimcoreTargetLanguages: ['en'],
translationContext: $objectTranslationContext,
skipExistingTranslation: true,
allowInheritedValues: true,
doPublishVersion: true
);