public function LocaleSource::saveTranslation

Saves a translation.

Parameters

\Drupal\tmgmt\JobItemInterface $job_item: The job item entity.

string $target_langcode: The target language code.

Return value

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

Overrides SourcePluginInterface::saveTranslation

File

sources/locale/src/Plugin/tmgmt/Source/LocaleSource.php, line 211

Class

LocaleSource
Translation Source plugin for locale strings.

Namespace

Drupal\tmgmt_locale\Plugin\tmgmt\Source

Code

public function saveTranslation(JobItemInterface $job_item, $target_langcode) {
  $data = $job_item
    ->getData();
  if (isset($data['singular'])) {
    $translation = $data['singular']['#translation']['#text'];

    // Update the locale string in the system.
    // @todo: Send error message to user if update fails.
    if ($this
      ->updateTranslation($job_item
      ->getItemId(), $target_langcode, $translation)) {
      return TRUE;
    }
  }
  return FALSE;
}