You are here

protected function SmartlingTranslator::addSmartlingDirectives in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/tmgmt/Translator/SmartlingTranslator.php \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator::addSmartlingDirectives()

Adds smartling directives to upload parameters.

Array of directives can be altered by `tmgmt_smartling_directives_alter` hook.

Parameters

\Smartling\File\Params\UploadFileParameters $params:

\Drupal\tmgmt\JobInterface $job:

Return value

\Smartling\File\Params\UploadFileParameters

2 calls to SmartlingTranslator::addSmartlingDirectives()
SmartlingTranslator::requestTranslation in src/Plugin/tmgmt/Translator/SmartlingTranslator.php
@abstract
SmartlingTranslatorBeingTested::addSmartlingDirectives in tests/src/Kernel/SmartlingTranslatorTest.php
Adds smartling directives to upload parameters.
1 method overrides SmartlingTranslator::addSmartlingDirectives()
SmartlingTranslatorBeingTested::addSmartlingDirectives in tests/src/Kernel/SmartlingTranslatorTest.php
Adds smartling directives to upload parameters.

File

src/Plugin/tmgmt/Translator/SmartlingTranslator.php, line 358
Contains \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator.

Class

SmartlingTranslator
Smartling translator plugin.

Namespace

Drupal\tmgmt_smartling\Plugin\tmgmt\Translator

Code

protected function addSmartlingDirectives(UploadFileParameters $params, JobInterface $job) {
  $directives = [
    'smartling.translate_paths' => 'html/body/div/div, html/body/div/span',
    'smartling.string_format_paths' => 'html : html/body/div/div, @default : html/body/div/span',
    'smartling.variants_enabled' => 'true',
    'smartling.source_key_paths' => 'html/body/div/{div.sl-variant}, html/body/div/{span.sl-variant}',
    'smartling.character_limit_paths' => 'html/body/div/limit',
    'smartling.placeholder_format_custom' => $job
      ->getSetting('custom_regexp_placeholder'),
  ];
  $this->moduleHandler
    ->alter('tmgmt_smartling_directives', $directives);
  if (is_array($directives)) {
    $directives = $this
      ->filterDirectives($directives);
    foreach ($directives as $directive_name => $directive_value) {
      $params
        ->set($directive_name, $directive_value);
    }
  }
  return $params;
}