\Geekwright\PoPoEntry

PoEntry represent a single entry in a GNU gettext style PO or POT file.

An entry consists of an associative array of values, indexed by type. These types are based on PO file line recognition tokens from PoTokens.

Summary

Methods
Properties
Constants
__construct()
add()
addQuoted()
addQuotedAtPosition()
get()
getAsString()
getAsStringArray()
set()
dumpEntry()
hasFlag()
addFlag()
No public properties found
No constants found
dumpEntryComments()
formatQuotedString()
$entry
N/A
No private methods found
No private properties found
N/A

Properties

$entry

$entry : array

Type

array

Methods

__construct()

__construct() : mixed

establish an empty entry

Returns

mixed —

add()

add(string  $type, string  $value) : void

add a value to an array 'type' in the entry

Parameters

string $type

PoToken constant

string $value

value to store

addQuoted()

addQuoted(string  $type, string  $value) : void

add a quoted value to the array 'type' in the entry

Parameters

string $type

PoToken constant

string $value

value to store

addQuotedAtPosition()

addQuotedAtPosition(string  $type, int  $position, string  $value) : void

add a quoted value to the nested array 'type' in the entry

This is mainly useful for translated plurals. Since any plural msgstr can have continuation lines, the message is stored as an array of arrays.

Parameters

string $type

PoToken constant

int $position

array position to store

string $value

value to store

get()

get(string  $type) : string|string[]|null

get the value for a specified type

Parameters

string $type

PoToken constant

Returns

string|string[]|null —

getAsString()

getAsString(string  $type) : string|null

get the value of a specified type as a string

Parameters

string $type

PoToken constant

Returns

string|null —

getAsStringArray()

getAsStringArray(string  $type) : string[]|null

Get the value of a specified type as an array of strings. This is mainly for plural TRANSLATED messages.

Parameters

string $type

PoToken constant

Returns

string[]|null —

set()

set(string  $type, string|string[]|null  $value) : void

set the value of a specified type

Parameters

string $type

PoToken constant

string|string[]|null $value

value to set

dumpEntry()

dumpEntry() : string

Dump this entry as a po/pot file fragment

Returns

string —

hasFlag()

hasFlag(string  $name) : bool

check for presence of a flag

Parameters

string $name

flag to check

Returns

bool —

true if flag is set, otherwise false

addFlag()

addFlag(string  $name) : void

add a flag to the entry

Parameters

string $name

flag to check

dumpEntryComments()

dumpEntryComments() : string

Dump the comments for this entry as a po/pot file fragment

Returns

string —

formatQuotedString()

formatQuotedString(string|string[]|null  $value, bool  $bare = false) : string

format a string for output by escaping control and double quote characters, then surrounding with double quotes

Parameters

string|string[]|null $value

string to prepare

bool $bare

true for bare output, default false adds leading space and trailing newline

Returns

string —