\Lobbygettext_reader

Provides a simple gettext replacement that works independently from the system's gettext abilities.

It can read MO files and use them for translating strings. The files are passed to gettext_reader as a Stream (see streams.php)

This version has the ability to cache all strings and translations to speed up the string lookup. While the cache is enabled by default, it can be switched off with the second parameter in the constructor (e.g. whenusing very large MO files that you don't want to keep in memory)

Summary

Methods
Properties
Constants
readint()
readintarray()
gettext_reader()
load_tables()
get_original_string()
get_translation_string()
find_string()
translate()
get_plural_forms()
select_string()
ngettext()
$error
$BYTEORDER
$STREAM
$short_circuit
$enable_cache
$originals
$translations
$pluralheader
$total
$table_originals
$table_translations
$cache_translations
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$error

$error : 

Type

$BYTEORDER

$BYTEORDER : 

Type

$STREAM

$STREAM : 

Type

$short_circuit

$short_circuit : 

Type

$enable_cache

$enable_cache : 

Type

$originals

$originals : 

Type

$translations

$translations : 

Type

$pluralheader

$pluralheader : 

Type

$total

$total : 

Type

$table_originals

$table_originals : 

Type

$table_translations

$table_translations : 

Type

$cache_translations

$cache_translations : 

Type

Methods

readint()

readint() : Integer

Reads a 32bit Integer from the Stream

Returns

Integer —

from the Stream

readintarray()

readintarray(  $count) : Array

Reads an array of Integers from the Stream

Parameters

$count

Returns

Array —

of Integers

gettext_reader()

gettext_reader(  $Reader,   $enable_cache = true) 

Constructor

Parameters

$Reader
$enable_cache

load_tables()

load_tables() 

Loads the translation tables from the MO file into the cache If caching is enabled, also loads all strings into a cache to speed up translation lookups

get_original_string()

get_original_string(  $num) : string

Returns a string from the "originals" table

Parameters

$num

Returns

string —

Requested string if found, otherwise ''

get_translation_string()

get_translation_string(  $num) : string

Returns a string from the "translations" table

Parameters

$num

Returns

string —

Requested string if found, otherwise ''

find_string()

find_string(  $string,   $start = -1,   $end = -1) : integer

Binary search for string

Parameters

$string
$start
$end

Returns

integer —

string number (offset in originals table)

translate()

translate(  $string) : string

Translates a string

Parameters

$string

Returns

string —

translated string (or original, if not found)

get_plural_forms()

get_plural_forms() : string

Get possible plural forms from MO header

Returns

string —

plural form header

select_string()

select_string(  $n) : integer

Detects which plural form to take

Parameters

$n

Returns

integer —

array index of the right plural form

ngettext()

ngettext(  $single,   $plural,   $number) : \Lobby\translated

Plural version of gettext

Parameters

$single
$plural
$number

Returns

\Lobby\translated —

plural form