private function PoStreamReader::readHeader

private PoStreamReader::readHeader()

Read the header from the PO stream.

The header is a special case PoItem, using the empty string as source and key-value pairs as translation. We just reuse the item reader logic to read the header.

File

core/lib/Drupal/Component/Gettext/PoStreamReader.php, line 216

Class

PoStreamReader
Implements Gettext PO stream reader.

Namespace

Drupal\Component\Gettext

Code

private function readHeader() {
  $item = $this->readItem();
  // Handle the case properly when the .po file is empty (0 bytes).
  if (!$item) {
    return;
  }
  $header = new PoHeader();
  $header->setFromString(trim($item->getTranslation()));
  $this->_header = $header;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Gettext!PoStreamReader.php/function/PoStreamReader::readHeader/8.1.x