You are here

public function TMGMTI18nStringSourcePluginController::saveTranslation in Translation Management Tool 7

Saves a translation.

Parameters

TMGMTJobItem $job_item: The job item entity.

Return value

boolean TRUE if the translation was saved successfully, FALSE otherwise.

Overrides TMGMTSourcePluginControllerInterface::saveTranslation

File

sources/i18n_string/tmgmt_i18n_string.plugin.inc, line 58
Provides the i18n string source controller.

Class

TMGMTI18nStringSourcePluginController
Translation plugin controller for i18n strings.

Code

public function saveTranslation(TMGMTJobItem $job_item) {
  $job = tmgmt_job_load($job_item->tjid);
  $data = array_filter(tmgmt_flatten_data($job_item
    ->getData()), '_tmgmt_filter_data');
  foreach ($data as $i18n_string => $item) {
    if (isset($item['#translation']['#text'])) {
      i18n_string_translation_update($i18n_string, $item['#translation']['#text'], $job->target_language);
    }
  }

  // We just saved the translation, set the state of the job item to
  // 'finished'.
  $job_item
    ->accepted();
}