package pomo
inherited_from \Gettext_Translations

 Methods

add_comment_to_entry()

add_comment_to_entry(\Translation_Entry $entry, string $po_comment_line) 

Parameters

$entry

\Translation_Entry

$po_comment_line

string

Add entry to the PO structure

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

Parameters

$entry

array\Translation_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

Prepare a text as a comment -- wraps the lines and prepends # and a special character to each line

comment_block(string $text, string $char = ' '
Static
access private

Parameters

$text

string

the comment text

$char

string

character to denote a special PO comment, like :, default is a space

Exports the whole PO file as a string

export(boolean $include_headers = true) : string

Parameters

$include_headers

boolean

whether to include the headers in the export

Returns

stringready for inclusion in PO file string for headers and all the enrtries

Exports all entries to PO format

export_entries() : string

Returns

stringsequence of mgsgid/msgstr PO strings, doesn't containt newline at the end

Builds a string from the entry for inclusion in PO file

export_entry(\Translation_Entry $entry) : false | string
Static

Parameters

$entry

\Translation_Entry

the entry to convert to po string (passed by reference).

Returns

falsestringPO-style formatted string for the entry or false if the entry is empty

Exports headers to a PO entry

export_headers() : string

Returns

stringmsgid/msgstr PO entry for this PO file headers, doesn't contain newline at the end

Same as {@link export}, but writes the result to a file

export_to_file(string $filename, boolean $include_headers = true) : boolean

Parameters

$filename

string

where to write the PO string

$include_headers

boolean

whether to include tje headers in the export

Returns

booleantrue on success, false on error

get_header()

get_header(string $header) 
Inherited

Parameters

$header

string

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

import_from_file()

import_from_file(string $filename) : boolean

Parameters

$filename

string

Returns

boolean

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

match_begin_and_end_newlines()

match_begin_and_end_newlines($translation, $original) 
Static

Parameters

$translation

$original

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

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

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

Formats a string in PO-style

poify(string $string) : string
Static

Parameters

$string

string

the string to format

Returns

stringthe poified string

Inserts $with in the beginning of every new line of $string and returns the modified string

prepend_each_line(string $string, string $with) 
Static

Parameters

$string

string

prepend lines in this string

$with

string

prepend lines with this string

read_entry()

read_entry(resource $f, integer $lineno = 0) : null | false | array

Parameters

$f

resource

$lineno

integer

Returns

nullfalsearray

read_line()

read_line(resource $f, string $action = 'read') : boolean
staticvar string $last_line
staticvar boolean $use_last_line

Parameters

$f

resource

$action

string

Returns

boolean

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

Parameters

$count

integer

number of items

Text to include as a comment before the start of the PO contents

set_comment_before_headers($text) 

Doesn't need to include # in the beginning of lines, these are added automatically

Parameters

$text

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

trim_quotes()

trim_quotes(string $s) : \sring
Static

Parameters

$s

string

Returns

\sring

Gives back the original string from a PO-formatted string

unpoify(string $string) : string
Static

Parameters

$string

string

PO-formatted string

Returns

stringenascaped string

Helper function for read_entry

is_final(string $context) : boolean
Static

Parameters

$context

string

Returns

boolean

 Properties

 

$comments_before_headers

$comments_before_headers 

Default

''
 

$entries

$entries 

Default

array()
 

$headers

$headers 

Default

array()