XOOPS RMCommon Utilities
2.1.8.91RC
|
Public Member Functions | |
find_string ($string, $start=-1, $end=-1) | |
get_original_string ($num) | |
get_plural_forms () | |
get_translation_string ($num) | |
gettext_reader ($Reader, $enable_cache=true) | |
load_tables () | |
ngettext ($single, $plural, $number) | |
read ($bytes) | |
readint () | |
readintarray ($count) | |
sanitize_plural_expression ($expr) | |
select_string ($n) | |
translate ($string) | |
Public Attributes | |
$BYTEORDER = 0 | |
$cache_translations = NULL | |
$enable_cache = false | |
$error = 0 | |
$originals = NULL | |
$pluralheader = NULL | |
$short_circuit = false | |
$STREAM = NULL | |
$table_originals = NULL | |
$table_translations = NULL | |
$total = 0 | |
$translations = NULL | |
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)
Definition at line 36 of file gettext.php.
gettext_reader::find_string | ( | $string, | |
$start = -1 , |
|||
$end = -1 |
|||
) |
Binary search for string
private
string | string |
int | start (internally used in recursive function) |
int | end (internally used in recursive function) |
Definition at line 208 of file gettext.php.
References $start, $total, and get_original_string().
Referenced by ngettext(), and translate().
gettext_reader::get_original_string | ( | $num | ) |
Returns a string from the "originals" table
private
int | num Offset number of original string |
Definition at line 172 of file gettext.php.
References $data.
Referenced by find_string().
gettext_reader::get_plural_forms | ( | ) |
Get possible plural forms from MO header
private
Definition at line 309 of file gettext.php.
References $pluralheader, get_translation_string(), load_tables(), and sanitize_plural_expression().
Referenced by select_string().
gettext_reader::get_translation_string | ( | $num | ) |
Returns a string from the "translations" table
private
int | num Offset number of original string |
Definition at line 189 of file gettext.php.
References $data.
Referenced by get_plural_forms(), ngettext(), and translate().
gettext_reader::gettext_reader | ( | $Reader, | |
$enable_cache = true |
|||
) |
Constructor
object | Reader the StreamReader object |
boolean | enable_cache Enable or disable caching of strings (default on) |
Definition at line 101 of file gettext.php.
References $enable_cache, elseif(), error(), read(), and readint().
gettext_reader::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
private
Definition at line 140 of file gettext.php.
References $i, $total, and readintarray().
Referenced by get_plural_forms(), and translate().
gettext_reader::ngettext | ( | $single, | |
$plural, | |||
$number | |||
) |
Plural version of gettext
public
string | single |
string | plural |
string | number |
Definition at line 361 of file gettext.php.
References $result, find_string(), get_translation_string(), and select_string().
gettext_reader::read | ( | $bytes | ) |
Definition at line 75 of file gettext.php.
Referenced by gettext_reader().
gettext_reader::readint | ( | ) |
Reads a 32bit Integer from the Stream
private
Definition at line 63 of file gettext.php.
Referenced by gettext_reader().
gettext_reader::readintarray | ( | $count | ) |
Reads an array of Integers from the Stream
int | count How many elements should be read |
Definition at line 85 of file gettext.php.
Referenced by load_tables().
gettext_reader::sanitize_plural_expression | ( | $expr | ) |
Sanitize plural form expression for use in PHP eval call.
private
Definition at line 274 of file gettext.php.
Referenced by get_plural_forms().
gettext_reader::select_string | ( | $n | ) |
Detects which plural form to take
private
n | count |
Definition at line 338 of file gettext.php.
References $total, and get_plural_forms().
Referenced by ngettext().
gettext_reader::translate | ( | $string | ) |
Translates a string
public
string | string to be translated |
Definition at line 247 of file gettext.php.
References find_string(), get_translation_string(), and load_tables().
gettext_reader::$BYTEORDER = 0 |
Definition at line 41 of file gettext.php.
gettext_reader::$cache_translations = NULL |
Definition at line 51 of file gettext.php.
gettext_reader::$enable_cache = false |
Definition at line 44 of file gettext.php.
Referenced by gettext_reader().
gettext_reader::$error = 0 |
Definition at line 38 of file gettext.php.
gettext_reader::$originals = NULL |
Definition at line 45 of file gettext.php.
gettext_reader::$pluralheader = NULL |
Definition at line 47 of file gettext.php.
Referenced by get_plural_forms().
gettext_reader::$short_circuit = false |
Definition at line 43 of file gettext.php.
gettext_reader::$STREAM = NULL |
Definition at line 42 of file gettext.php.
gettext_reader::$table_originals = NULL |
Definition at line 49 of file gettext.php.
gettext_reader::$table_translations = NULL |
Definition at line 50 of file gettext.php.
gettext_reader::$total = 0 |
Definition at line 48 of file gettext.php.
Referenced by find_string(), load_tables(), and select_string().
gettext_reader::$translations = NULL |
Definition at line 46 of file gettext.php.