public function JobItemInterface::addTranslatedData in Translation Management Tool 8
Adds translated data to a job item.
This function calls for JobItem::addTranslatedDataRecursive() which sets the status of each added data item to TMGMT_DATA_ITEM_STATE_TRANSLATED.
Following rules apply while adding translated data:
1) Updated are only items that are changed. In case there is local modification the translation is added as a revision with a message stating this fact.
2) Merging happens at the data items level, so updating only those that are changed. If a data item is in review/reject status and is being updated with translation originating from remote the status is updated to 'translated' no matter if it is changed or not.
3) Each time a data item is updated the previous translation becomes a revision.
If all data items are translated, the status of the job item is updated to needs review.
@todo To update the job item status to needs review we could take advantage of the JobItem::getCountPending() and JobItem::getCountTranslated(). The catch is, that this counter gets updated while saveing which not yet hapened.
Parameters
array $translation: Nested array of translated data. Can either be a single text entry, the whole data structure or parts of it.
array|string $key: (Optional) Either a flattened key (a 'key1][key2][key3' string) or a nested one, e.g. array('key1', 'key2', 'key2'). Defaults to an empty array which means that it will replace the whole translated data array.
int|null $status: (Optional) The data item status that will be set. Defaults to NULL, which means that it will be set to translated unless it was previously set to preliminary, then it will keep that state. Explicitly pass TMGMT_DATA_ITEM_STATE_TRANSLATED or TMGMT_DATA_ITEM_STATE_PRELIMINARY to set it to that value. Other statuses are not supported.
Throws
\Drupal\tmgmt\TMGMTException If is given an unsupported status.
1 method overrides JobItemInterface::addTranslatedData()
- JobItem::addTranslatedData in src/
Entity/ JobItem.php - Adds translated data to a job item.
File
- src/
JobItemInterface.php, line 454
Class
- JobItemInterface
- Interface for tmgmt_job_item entity.
Namespace
Drupal\tmgmtCode
public function addTranslatedData(array $translation, $key = array(), $status = NULL);