Translation Jobs

A single task to translate something into a given language using a translator.

Attached to these jobs are job items, which specify which sources are to be translated.

To create a new translation job, first create a job and then assign items to each. Each item needs to specify the source plugin that should be used and the type and id, which the source plugin then uses to identify it later on.

$job = tmgmt_job_create('en', $target_language);
for ($i = 1; $i < 3; $i++) {
  $job
    ->addItem('test_source', 'test', $i);
}

Once a job has been created, it can be assigned to a translator plugin, which is the service that is going to do the translation.

$job->translator = 'test_translator';

// Translator specific settings.
$job->settings = array(
  'priority' => 5,
);
$job
  ->save();

// Get the translator plugin and request a translation.
if ($job
  ->isTranslatable()) {
  $job
    ->requestTranslation();
}

The translation plugin will then request the text from the source plugin. Depending on the plugin, the text might be sent to an external service or assign it to a local user or team of users. At some point, a translation will be returned and saved in the job items.

The translation can now be reviewed, accepted and the source plugins be told to save the translation.

$job
  ->accepted('Optional message');

File

./tmgmt.api.php, line 72
Hooks provided by the Translation Management module.

Functions

Name Locationsort descending Description
JobCheckoutManager::checkoutAndRedirect src/JobCheckoutManager.php Attempts to checkout a number of jobs and prepare the necessary redirects.
JobCheckoutManager::checkoutMultiple src/JobCheckoutManager.php Attempts to check out a number of jobs.
tmgmt_job_item_load_latest ./tmgmt.module Loads active job entities that have a job item with the identifiers.
tmgmt_job_item_load_all_latest ./tmgmt.module Loads all latest job entities that have a job item with the identifiers.
tmgmt_job_match_item ./tmgmt.module Returns a job which matches the requested source- and target language by user. If no job exists, a new job object will be created.
tmgmt_job_check_finished ./tmgmt.module Checks whether a job is finished by querying the job item table for unfinished job items.
tmgmt_job_create ./tmgmt.module Creates a translation job.
tmgmt_job_statistics_load ./tmgmt.module Loads an array with the word and status statistics of a job.
tmgmt_job_statistic ./tmgmt.module Returns a specific statistic of a job.
tmgmt_job_item_create ./tmgmt.module Creates a translation job item.
tmgmt_message_create ./tmgmt.module Creates a translation job message.
tmgmt_job_checkout_multiple Deprecated ./tmgmt.module Attempts to check out a number of jobs. Performs a number of checks on each job and also allows to alter the behavior through hooks.
tmgmt_job_checkout_and_redirect ./tmgmt.module Attempts to checkout a number of jobs and prepare the necessary redirects.

Constants

Name Locationsort descending Description
TMGMT_DATA_ITEM_STATE_PENDING ./tmgmt.module The translation data item has not been translated.
TMGMT_DATA_ITEM_STATE_REVIEWED ./tmgmt.module The translation data item has been reviewed.
TMGMT_DATA_ITEM_STATE_TRANSLATED ./tmgmt.module The translation data item has been translated.
TMGMT_DATA_ITEM_STATE_ACCEPTED ./tmgmt.module The translation data item has been reviewed.
TMGMT_DATA_ITEM_STATE_PRELIMINARY ./tmgmt.module The translation data item has been reviewed.

Classes

Name Locationsort descending Description
Job src/Entity/Job.php Entity class for the tmgmt_job entity.
JobItem src/Entity/JobItem.php Entity class for the tmgmt_job_item entity.
Message src/Entity/Message.php Entity class for the tmgmt_message entity.
RemoteMapping src/Entity/RemoteMapping.php Entity class for the tmgmt_remote entity.
ContinuousJobForm src/Form/ContinuousJobForm.php Form controller for the job edit forms.
JobForm src/Form/JobForm.php Form controller for the job edit forms.
JobItemForm src/Form/JobItemForm.php Form controller for the job item edit forms.
TmgmtFormBase src/Form/TmgmtFormBase.php Form controller for the job item edit forms.
JobCheckoutManager src/JobCheckoutManager.php Provides functionality related to job checkout and submissions.

Interfaces

Name Locationsort descending Description
JobInterface src/JobInterface.php Interface for tmgmt_job entity.
JobItemInterface src/JobItemInterface.php Interface for tmgmt_job_item entity.
MessageInterface src/MessageInterface.php Interface for the tmgmt_message entity.
RemoteMappingInterface src/RemoteMappingInterface.php Interface for the tmgmt_remote entity.