package pomo
inherited_from \Gettext_Translations

 Methods

Add entry to the PO structure

add_entry(array | \Translation_Entry $entry) : boolean
Inherited

Parameters

$entry

array\Translation_Entry

&$entry

Returns

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

add_entry_or_merge()

add_entry_or_merge(array|\Translation_Entry $entry) : boolean
Inherited

Parameters

$entry

array\Translation_Entry

Returns

boolean

export()

export() : string | false

Returns

stringfalse

export_headers()

export_headers() : string

Returns

string

export_original()

export_original(\Translation_Entry $entry) : string

Parameters

$entry

\Translation_Entry

Returns

string

export_to_file()

export_to_file(string $filename) : boolean

Parameters

$filename

string

Returns

boolean

export_to_file_handle()

export_to_file_handle(resource $fh) : true

Parameters

$fh

resource

Returns

true

export_translations()

export_translations(\Translation_Entry $entry) : string

Parameters

$entry

\Translation_Entry

Returns

string

get_byteorder()

get_byteorder(integer $magic) : string | false

Parameters

$magic

integer

Returns

stringfalse

get_header()

get_header(string $header) 
Inherited

Parameters

$header

string

get_plural_forms_count()

get_plural_forms_count() : integer

Returns

integer

get_plural_forms_count()

get_plural_forms_count() : integer
Inherited

Returns

integer

The gettext implementation of select_plural_form.

gettext_select_plural_form(integer $count) 
Inherited

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

integer

Fills up with the entries from MO file $filename

import_from_file(string $filename) 

Parameters

$filename

string

MO file to load

import_from_reader()

import_from_reader(\POMO_FileReader $reader) 

Parameters

$reader

\POMO_FileReader

is_entry_good_for_export()

is_entry_good_for_export(\Translation_Entry $entry) : boolean

Parameters

$entry

\Translation_Entry

Returns

boolean

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

make_entry(string $original, string $translation) 
Static
static

Parameters

$original

string

original string to translate from MO file. Might contain 0x04 as context separator or 0x00 as singular/plural separator

$translation

string

translation string from MO file. Might contain 0x00 as a plural translations separator

make_headers()

make_headers(string $translation) : array
Inherited

Parameters

$translation

string

Returns

array

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

make_plural_form_function(integer $nplurals, string $expression) 
Inherited

Parameters

$nplurals

integer

$expression

string

merge_originals_with()

merge_originals_with(object $other) 
Inherited

Parameters

$other

object

Merge $other in the current object.

merge_with(Object $other) : void
Inherited

Parameters

$other

Object

&$other Another Translation object, whose translations will be merged in this one

nplurals_and_expression_from_header()

nplurals_and_expression_from_header(string $header) : array
Inherited

Parameters

$header

string

Returns

array

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

parenthesize_plural_exression(string $expression) : string
Inherited

Parameters

$expression

string

the expression without parentheses

Returns

stringthe expression with parentheses added

select_plural_form()

select_plural_form(integer $count) : string

Parameters

$count

integer

Returns

string

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

select_plural_form(integer $count) 
Inherited

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

$count

integer

number of items

Sets $header PO header to $value

set_header(string $header, string $value) 
Inherited

If the header already exists, it will be overwritten

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

Parameters

$header

string

header name, without trailing :

$value

string

header value, without trailing \n

set_headers()

set_headers(array $headers) 
Inherited

Parameters

$headers

array

translate()

translate(string $singular, string $context = null) : string
Inherited

Parameters

$singular

string

$context

string

Returns

string

translate_entry()

translate_entry(\Translation_Entry $entry) 
Inherited

Parameters

$entry

\Translation_Entry

translate_plural()

translate_plural(string $singular, string $plural, integer $count, string $context = null
Inherited

Parameters

$singular

string

$plural

string

$count

integer

$context

string

 Properties

 

$_nplurals

$_nplurals 

Default

2
 

$entries

$entries 

Default

array()
 

$headers

$headers 

Default

array()