protected function DrupalTranslator::processParameters

Processes the parameters array for use with t().

2 calls to DrupalTranslator::processParameters()

File

drupal/core/lib/Drupal/Core/Validation/DrupalTranslator.php, line 65
Contains \Drupal\Core\Validation\DrupalTranslator.

Class

DrupalTranslator
Translates strings using Drupal's translation system.

Namespace

Drupal\Core\Validation

Code

protected function processParameters(array $parameters) {
  $return = array();
  foreach ($parameters as $key => $value) {
    if (is_object($value)) {

      // t() does not work will objects being passed as replacement strings.
    }
    elseif (strpos($key, '{{ ') === 0 && strrpos($key, ' }}') == strlen($key) - 3) {

      // Transform it into a Drupal pattern using the format %name.
      $key = '%' . substr($key, 3, strlen($key) - 6);
      $return[$key] = $value;
    }
    else {
      $return[$key] = $value;
    }
  }
  return $return;
}