You are here

public function UpdateTranslations::execute in DRD Agent 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Agent/Action/UpdateTranslations.php \Drupal\drd_agent\Agent\Action\UpdateTranslations::execute()

Execute an action.

Return value

mixed The response of the action as an array which will be encrypted before returned to DRD.

Overrides Base::execute

File

src/Agent/Action/UpdateTranslations.php, line 13

Class

UpdateTranslations
Provides a 'UpdateTranslations' code.

Namespace

Drupal\drd_agent\Agent\Action

Code

public function execute() {
  if ($this->moduleHandler
    ->moduleExists('locale')) {
    $this->moduleHandler
      ->loadInclude('locale', 'fetch.inc');
    $this->moduleHandler
      ->loadInclude('locale', 'bulk.inc');
    $langcodes = array_keys(locale_translatable_language_list());

    // Set the translation import options. This determines if existing
    // translations will be overwritten by imported strings.
    $options = _locale_translation_default_update_options();
    locale_translation_clear_status();
    $batch = locale_translation_batch_update_build([], $langcodes, $options);
    batch_set($batch);

    // Set a batch to update configuration as well.
    if ($batch = locale_config_batch_update_components($options, $langcodes)) {
      batch_set($batch);
    }
    batch_process();

    // Allow other modules as well to jump in with translation update routines.
    $this->moduleHandler
      ->invokeAll('drd_agent_update_translation');
  }
  return [];
}