Properties

$_nplurals

$_nplurals

$entries

$entries

$headers

$headers

Methods

import_from_file()

import_from_file(string $filename)

Fills up with the entries from MO file $filename

Parameters

string $filename

MO file to load

export_to_file()

export_to_file( $filename)

Parameters

$filename

export()

export()

is_entry_good_for_export()

is_entry_good_for_export( $entry)

Parameters

$entry

export_to_file_handle()

export_to_file_handle( $fh)

Parameters

$fh

export_original()

export_original( $entry)

Parameters

$entry

export_translations()

export_translations( $entry)

Parameters

$entry

export_headers()

export_headers()

get_byteorder()

get_byteorder( $magic)

Parameters

$magic

import_from_reader()

import_from_reader( $reader)

Parameters

$reader

make_entry()

make_entry(string $original, string $translation)

Build a Translation_Entry from original string and translation strings, found in a MO file

Parameters

string $original

original string to translate from MO file. Might contain

0x04 as context separator or 0x00 as singular/plural separator
string $translation

translation string from MO file. Might contain

0x00 as a plural translations separator

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()

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

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