class PoStreamReader implements PoStreamInterface, PoReaderInterface (View source)

Implements Gettext PO stream reader.

The PO file format parsing is implemented according to the documentation at http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files

Properties

protected int $lineNumber

Source line number of the stream being parsed.

protected string $context

Parser context for the stream reader state machine.

protected array $currentItem

Current entry being read. Incomplete.

protected int $currentPluralIndex

Current plural index for plural translations.

protected string $uri

URI of the PO stream that is being read.

protected string $langcode

Language code for the PO stream being read.

protected resource $fd

File handle of the current PO stream.

protected PoHeader $header

The PO stream header.

protected PoItem $lastItem

Object wrapper for the last read source/translation pair.

protected bool $finished

Indicator of whether the stream reading is finished.

protected array $errors

Array of translated error strings recorded on reading this stream so far.

Methods

string
getLangcode()

Get language code.

setLangcode(string $langcode)

Set language code.

getHeader()

Get header metadata.

setHeader(PoHeader $header)

Implements Drupal\Component\Gettext\PoMetadataInterface::setHeader().

URI
getURI()

Gets the URI of the PO stream that is being read or written.

setURI($uri)

Set the URI of the PO stream that is going to be read or written.

open()

Implements Drupal\Component\Gettext\PoStreamInterface::open().

close()

Implements Drupal\Component\Gettext\PoStreamInterface::close().

readItem()

Reads and returns a PoItem (source/translation pair).

setSeek(int $seek)

Sets the seek position for the current PO stream.

getSeek()

Gets the pointer position of the current PO stream.

setItemFromArray($value)

Store the parsed values as a PoItem object.

The
parseQuoted($string)

Parses a string in quotes.

Details

string getLangcode()

Get language code.

Return Value

string

Language code string.

setLangcode(string $langcode)

Set language code.

Parameters

string $langcode

Language code string.

PoHeader getHeader()

Get header metadata.

Return Value

PoHeader

Header instance representing metadata in a PO header.

setHeader(PoHeader $header)

Implements Drupal\Component\Gettext\PoMetadataInterface::setHeader().

Not applicable to stream reading and therefore not implemented.

Parameters

PoHeader $header

Header object representing metadata in a PO header.

URI getURI()

Gets the URI of the PO stream that is being read or written.

Return Value

URI

string for this stream.

setURI($uri)

Set the URI of the PO stream that is going to be read or written.

Parameters

$uri

URI string to set for this stream.

open()

Implements Drupal\Component\Gettext\PoStreamInterface::open().

Opens the stream and reads the header. The stream is ready for reading items after.

Exceptions

Exception

close()

Implements Drupal\Component\Gettext\PoStreamInterface::close().

Exceptions

Exception

PoItem readItem()

Reads and returns a PoItem (source/translation pair).

Return Value

PoItem

Wrapper for item data instance.

setSeek(int $seek)

Sets the seek position for the current PO stream.

Parameters

int $seek

The new seek position to set.

getSeek()

Gets the pointer position of the current PO stream.

setItemFromArray($value)

Store the parsed values as a PoItem object.

Parameters

$value

The parseQuoted($string)

Parses a string in quotes.

Parameters

$string

A string specified with enclosing quotes.

Return Value

The

string parsed from inside the quotes.