You are here

public function PoStreamReader::setItemFromArray in Localization update 7.2

Store the parsed values as a PoItem object.

1 call to PoStreamReader::setItemFromArray()
PoStreamReader::readLine in includes/gettext/PoStreamReader.php
Reads a line from the PO stream and stores data internally.

File

includes/gettext/PoStreamReader.php, line 520
Contains \Drupal\Component\Gettext\PoStreamReader.

Class

PoStreamReader
Implements Gettext PO stream reader.

Code

public function setItemFromArray($value) {
  $plural = FALSE;
  $comments = '';
  $textgroup = 'default';
  if (isset($value['#'])) {
    $comments = $this
      ->shortenComments($value['#']);
    $textgroup = $this
      ->fetchGroupFromComment($comments);
  }
  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);
  $item
    ->setTextgroup($textgroup);
  $this->_last_item = $item;
  $this->_context = 'COMMENT';
}