Properties

$entries

$entries

$headers

$headers

Methods

gettext_select_plural_form()

gettext_select_plural_form( $count)

The gettext implementation of select_plural_form.

It lives in this class, because there are more than one descendand, which will use it and they can't share it effectively.

Parameters

$count

nplurals_and_expression_from_header()

nplurals_and_expression_from_header( $header)

Parameters

$header

make_plural_form_function()

make_plural_form_function( $nplurals,  $expression)

Makes a function, which will return the right translation index, according to the plural forms header

Parameters

$nplurals
$expression

parenthesize_plural_exression()

parenthesize_plural_exression(string $expression) : string

Adds parantheses to the inner parts of ternary operators in plural expressions, because PHP evaluates ternary oerators from left to right

Parameters

string $expression

the expression without parentheses

Returns

string —

the expression with parentheses added

make_headers()

make_headers( $translation)

Parameters

$translation

set_header()

set_header(string $header, string $value)

Sets $header PO header to $value

If the header already exists, it will be overwritten

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

Parameters

string $header

header name, without trailing :

string $value

header value, without trailing \n

add_entry()

add_entry( $entry) : bool

Add entry to the PO structure

Parameters

$entry

Returns

bool —

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

add_entry_or_merge()

add_entry_or_merge( $entry)

Parameters

$entry

set_headers()

set_headers( $headers)

Parameters

$headers

get_header()

get_header( $header)

Parameters

$header

translate_entry()

translate_entry( $entry)

Parameters

$entry

translate()

translate( $singular,  $context)

Parameters

$singular
$context

select_plural_form()

select_plural_form(integer $count)

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

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 overrided by the sub-classes. For example MO/PO can derive the logic from their headers.

Parameters

integer $count

number of items

get_plural_forms_count()

get_plural_forms_count()

translate_plural()

translate_plural( $singular,  $plural,  $count,  $context)

Parameters

$singular
$plural
$count
$context

merge_with()

merge_with( $other) : void

Merge $other in the current object.

Parameters

$other

merge_originals_with()

merge_originals_with( $other)

Parameters

$other