You are here

public function PoItem::setFromArray in Service Container 7.2

Same name and namespace in other branches
  1. 7 lib/Drupal/Component/Gettext/PoItem.php \Drupal\Component\Gettext\PoItem::setFromArray()

Create the PoItem from a structured array.

Parameters

array values:

File

lib/Drupal/Component/Gettext/PoItem.php, line 179
Contains \Drupal\Component\Gettext\PoItem.

Class

PoItem
PoItem handles one translation.

Namespace

Drupal\Component\Gettext

Code

public function setFromArray(array $values = array()) {
  if (isset($values['context'])) {
    $this
      ->setContext($values['context']);
  }
  if (isset($values['source'])) {
    $this
      ->setSource($values['source']);
  }
  if (isset($values['translation'])) {
    $this
      ->setTranslation($values['translation']);
  }
  if (isset($values['comment'])) {
    $this
      ->setComment($values['comment']);
  }
  if (isset($this->_source) && strpos($this->_source, LOCALE_PLURAL_DELIMITER) !== FALSE) {
    $this
      ->setSource(explode(LOCALE_PLURAL_DELIMITER, $this->_source));
    $this
      ->setTranslation(explode(LOCALE_PLURAL_DELIMITER, $this->_translation));
    $this
      ->setPlural(count($this->_source) > 1);
  }
}