package pomo

 Methods

Adds an entry to the PO structure.

add_entry(array|\Translation_Entry $entry) : boolean
since 2.8.0

Parameters

$entry

array\Translation_Entry

Returns

booleanTrue on success, false if the entry doesn't have a key.

Adds or merges an entry to the PO structure.

add_entry_or_merge(array|\Translation_Entry $entry) : boolean
since 2.8.0

Parameters

$entry

array\Translation_Entry

Returns

booleanTrue on success, false if the entry doesn't have a key.

Returns a given translation header.

get_header(string $header) : string | false
since 2.8.0

Parameters

$header

string

Returns

stringfalseHeader if it exists, false otherwise.

Returns the plural forms count.

get_plural_forms_count() : integer
since 2.8.0

Returns

integerPlural forms count.

Merges originals with existing entries.

merge_originals_with(\Translations $other) 
since 2.8.0

Parameters

$other

\Translations

Merges other translations into the current one.

merge_with(\Translations $other) 
since 2.8.0

Parameters

$other

\Translations

Another Translation object, whose translations will be merged in this one (passed by reference).

Given the number of items, returns the 0-based index of the plural form to use

select_plural_form(integer $count) : integer

Here, in the base Translations class, the common logic for English is implemented: 0 if there is one element, 1 otherwise

This function should be overridden by the subclasses. For example MO/PO can derive the logic from their headers.

since 2.8.0

Parameters

$count

integer

Number of items.

Returns

integerPlural form to use.

Sets $header PO header to $value

set_header(string $header, string $value) 

If the header already exists, it will be overwritten

TODO: this should be out of this class, it is gettext specific

since 2.8.0

Parameters

$header

string

header name, without trailing :

$value

string

header value, without trailing \n

Sets translation headers.

set_headers(array $headers) 
since 2.8.0

Parameters

$headers

array

Associative array of headers.

Translates a singular string.

translate(string $singular, string $context = null) : string
since 2.8.0

Parameters

$singular

string

$context

string

Returns

string

Returns a given translation entry.

translate_entry(\Translation_Entry $entry) : \Translation_Entry | false
since 2.8.0

Parameters

$entry

\Translation_Entry

Translation entry.

Returns

\Translation_EntryfalseTranslation entry if it exists, false otherwise.

Translates a plural string.

translate_plural(string $singular, string $plural, integer $count, string $context = null) : string
since 2.8.0

Parameters

$singular

string

$plural

string

$count

integer

$context

string

Returns

string

 Properties

 

List of translation entries.

$entries : array<mixed,\Translation_Entry>

Default

array()
since 2.8.0
 

List of translation headers.

$headers : \array<string,

Default

array()
since 2.8.0