Gettext_Translations class.
| package | pomo |
|---|---|
| inherited_from | \Gettext_Translations |
add_entry(array|\Translation_Entry $entry) : boolean
| since | 2.8.0 |
|---|
array\Translation_Entry
booleanTrue on success, false if the entry doesn't have a key.add_entry_or_merge(array|\Translation_Entry $entry) : boolean
| since | 2.8.0 |
|---|
array\Translation_Entry
booleanTrue on success, false if the entry doesn't have a key.comment_block(string $text, string $char = ' ')
| access | private |
|---|
stringthe comment text
stringcharacter to denote a special PO comment, like :, default is a space
export(boolean $include_headers = true) : string
booleanwhether to include the headers in the export
stringready for inclusion in PO file string for headers and all the entriesexport_entries() : string
stringsequence of msgid/msgstr PO strings, doesn't contain a newline at the endexport_entry(\Translation_Entry $entry) : string | false
\Translation_Entrythe entry to convert to po string.
stringfalsePO-style formatted string for the entry or
false if the entry is emptyexport_headers() : string
stringmsgid/msgstr PO entry for this PO file headers, doesn't contain newline at the endexport_to_file(string $filename, boolean $include_headers = true) : boolean
stringWhere to write the PO string.
booleanWhether to include the headers in the export.
booleantrue on success, false on errorget_header(string $header) : string | false
| since | 2.8.0 |
|---|
string
stringfalseHeader if it exists, false otherwise.get_plural_forms_count() : integer
| since | 2.8.0 |
|---|
integerPlural forms count.gettext_select_plural_form(integer $count) : integer
It lives in this class, because there are more than one descendant, which will use it and they can't share it effectively.
| since | 2.8.0 |
|---|
integerPlural forms count.
integerPlural form to use.import_from_file(string $filename) : boolean
string
booleanmake_headers(string $translation) : \array<string,
| since | 2.8.0 |
|---|
string
\array<string,string> Translation headersmake_plural_form_function(integer $nplurals, string $expression) : callable
| since | 2.8.0 |
|---|
integer
string
callablematch_begin_and_end_newlines($translation, $original)
merge_originals_with(\Translations $other)
| since | 2.8.0 |
|---|
\Translations
merge_with(\Translations $other)
| since | 2.8.0 |
|---|
\TranslationsAnother Translation object, whose translations will be merged in this one (passed by reference).
nplurals_and_expression_from_header(string $header) : \array{0:
| since | 2.8.0 |
|---|
string
\array{0:int, 1: string}parenthesize_plural_exression(string $expression) : string
poify(string $input_string) : string
stringthe string to format
stringthe poified stringprepend_each_line(string $input_string, string $with)
stringprepend lines in this string
stringprepend lines with this string
read_entry(resource $f, integer $lineno = 0) : null | false | array
resource
integer
nullfalsearray
read_line(resource $f, string $action = 'read') : boolean
resource
string
booleanselect_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 |
|---|
integerNumber of items.
integerPlural form to use.set_comment_before_headers(string $text)
Doesn't need to include # in the beginning of lines, these are added automatically
stringText to include as a comment.
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 |
|---|
stringheader name, without trailing :
stringheader value, without trailing \n
set_headers(array $headers)
| since | 2.8.0 |
|---|
arrayAssociative array of headers.
translate(string $singular, string $context = null) : string
| since | 2.8.0 |
|---|
string
string
stringtranslate_entry(\Translation_Entry $entry) : \Translation_Entry | false
| since | 2.8.0 |
|---|
\Translation_EntryTranslation entry.
\Translation_EntryfalseTranslation entry if it exists, false otherwise.translate_plural(string $singular, string $plural, integer $count, string $context = null) : string
| since | 2.8.0 |
|---|
string
string
integer
string
stringtrim_quotes(string $s) : string
string
stringunpoify(string $input_string) : string
stringPO-formatted string
stringunescaped stringis_final(string $context) : boolean
string
boolean$_gettext_select_plural_form : callable
| since | 2.8.0 |
|---|
$_nplurals : integer
| since | 2.8.0 |
|---|
$comments_before_headers
''$entries : array<mixed,\Translation_Entry>
array()| since | 2.8.0 |
|---|
$headers : \array<string,
array()| since | 2.8.0 |
|---|
add_comment_to_entry()
Parameters
$entry
\Translation_Entry$po_comment_line
string