function PoStreamReader::setItemFromArray
Same name in other branches
- 9 core/lib/Drupal/Component/Gettext/PoStreamReader.php \Drupal\Component\Gettext\PoStreamReader::setItemFromArray()
- 10 core/lib/Drupal/Component/Gettext/PoStreamReader.php \Drupal\Component\Gettext\PoStreamReader::setItemFromArray()
- 11.x core/lib/Drupal/Component/Gettext/PoStreamReader.php \Drupal\Component\Gettext\PoStreamReader::setItemFromArray()
Store the parsed values as a PoItem object.
1 call to PoStreamReader::setItemFromArray()
- PoStreamReader::readLine in core/
lib/ Drupal/ Component/ Gettext/ PoStreamReader.php - Reads a line from the PO stream and stores data internally.
File
-
core/
lib/ Drupal/ Component/ Gettext/ PoStreamReader.php, line 514
Class
- PoStreamReader
- Implements Gettext PO stream reader.
Namespace
Drupal\Component\GettextCode
public function setItemFromArray($value) {
$plural = FALSE;
$comments = '';
if (isset($value['#'])) {
$comments = $this->shortenComments($value['#']);
}
if (is_array($value['msgstr'])) {
// Sort plural variants by their form index.
ksort($value['msgstr']);
$plural = TRUE;
}
$item = new PoItem();
$item->setContext(isset($value['msgctxt']) ? $value['msgctxt'] : '');
$item->setSource($value['msgid']);
$item->setTranslation($value['msgstr']);
$item->setPlural($plural);
$item->setComment($comments);
$item->setLangcode($this->langcode);
$this->lastItem = $item;
$this->context = 'COMMENT';
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.