function PoHeader::parseHeader

Same name in other branches
  1. 9 core/lib/Drupal/Component/Gettext/PoHeader.php \Drupal\Component\Gettext\PoHeader::parseHeader()
  2. 8.9.x core/lib/Drupal/Component/Gettext/PoHeader.php \Drupal\Component\Gettext\PoHeader::parseHeader()
  3. 10 core/lib/Drupal/Component/Gettext/PoHeader.php \Drupal\Component\Gettext\PoHeader::parseHeader()

Parses a Gettext Portable Object file header.

Parameters

string $header: A string containing the complete header.

Return value

array An associative array of key-value pairs.

1 call to PoHeader::parseHeader()
PoHeader::setFromString in core/lib/Drupal/Component/Gettext/PoHeader.php
Populate internal values from a string.

File

core/lib/Drupal/Component/Gettext/PoHeader.php, line 253

Class

PoHeader
Gettext PO header handler.

Namespace

Drupal\Component\Gettext

Code

private function parseHeader($header) {
    $header_parsed = [];
    $lines = array_map('trim', explode("\n", $header));
    foreach ($lines as $line) {
        if ($line) {
            [
                $tag,
                $contents,
            ] = explode(":", $line, 2);
            $header_parsed[trim($tag)] = trim($contents);
        }
    }
    return $header_parsed;
}

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