function PoStreamReader::readHeader

Same name in other branches
  1. 9 core/lib/Drupal/Component/Gettext/PoStreamReader.php \Drupal\Component\Gettext\PoStreamReader::readHeader()
  2. 8.9.x core/lib/Drupal/Component/Gettext/PoStreamReader.php \Drupal\Component\Gettext\PoStreamReader::readHeader()
  3. 11.x core/lib/Drupal/Component/Gettext/PoStreamReader.php \Drupal\Component\Gettext\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.

1 call to PoStreamReader::readHeader()
PoStreamReader::open in core/lib/Drupal/Component/Gettext/PoStreamReader.php
Implements Drupal\Component\Gettext\PoStreamInterface::open().

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;
}

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