function PoItem::setFromArray

Same name in other branches
  1. 9 core/lib/Drupal/Component/Gettext/PoItem.php \Drupal\Component\Gettext\PoItem::setFromArray()
  2. 10 core/lib/Drupal/Component/Gettext/PoItem.php \Drupal\Component\Gettext\PoItem::setFromArray()
  3. 11.x core/lib/Drupal/Component/Gettext/PoItem.php \Drupal\Component\Gettext\PoItem::setFromArray()

Create the PoItem from a structured array.

Parameters

array $values:

File

core/lib/Drupal/Component/Gettext/PoItem.php, line 184

Class

PoItem
PoItem handles one translation.

Namespace

Drupal\Component\Gettext

Code

public function setFromArray(array $values = []) {
    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, self::DELIMITER) !== FALSE) {
        $this->setSource(explode(self::DELIMITER, $this->source));
        $this->setTranslation(explode(self::DELIMITER, $this->translation));
        $this->setPlural(count($this->source) > 1);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.