PHP Класс lithium\g11n\catalog\adapter\Gettext

The adapter works with the directory structure below. The example shows the structure for the directory as given by the 'path' configuration setting. It closely ressembles the standard gettext directory structure with a few slight adjustments to the way templates are being named. {{{ resources/g11n/po ├── | ├── LC_MESSAGES | | ├── default.po | | ├── default.mo | | ├── .po | | └── .mo | ├── LC_VALIDATION | | └── ... | └── ... ├── | └── ... ├── message_default.pot ├── message_.pot ├── validation_default.pot ├── validation_.pot └── ... }}}
См. также: lithium\g11n\Locale
Наследование: extends lithium\g11n\catalog\Adapter
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( array $config = [] ) : void Constructor.
read ( string $category, string $locale, string $scope ) : array Reads data.
write ( string $category, string $locale, string $scope, array $data ) : boolean Writes data.

Защищенные методы

Метод Описание
_compileMo ( resource $stream, array $data ) : void Compiles data into machine object (MO) format.
_compilePo ( resource $stream, array $data ) : boolean Compiles data into portable object (PO) format.
_compilePot ( resource $stream, array $data ) : boolean Compiles data into portable object template (POT) format.
_files ( string $category, string $locale, string $scope ) : array Returns absolute paths to files according to configuration.
_init ( ) : void Initializer. Checks if the configured path exists.
_merge ( array $data, array $item ) : array Merges an item into given data and unescapes fields.
_parseMo ( resource $stream ) : array Parses machine object (MO) format, independent of the machine's endian it was created on. Both 32bit and 64bit systems are supported.
_parsePo ( resource $stream ) : array Parses portable object (PO) format.
_parsePot ( resource $stream ) : array Parses portable object template (POT) format.
_prepareForWrite ( array $item ) : array Prepares an item before it is being written and escapes fields.
_readLong ( resource $stream, boolean $isBigEndian ) : integer Reads an unsigned long from stream respecting endianess.

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( array $config = [] ) : void
$config array Available configuration options are: - `'path'`: The path to the directory holding the data.
Результат void

_compileMo() защищенный Метод

Compiles data into machine object (MO) format.
protected _compileMo ( resource $stream, array $data ) : void
$stream resource
$data array
Результат void

_compilePo() защищенный Метод

To improve portability accross libraries the header is generated according to the format of the output of xgettext. This means using the same names for placeholders as well as including an empty entry. The empty entry at the beginning aids in parsing the file as it _attracts_ the preceding comments and following metadata when parsed which could otherwise be mistaken as a continued translation. The only difference in the header format is the initial header which just features one line of text.
protected _compilePo ( resource $stream, array $data ) : boolean
$stream resource
$data array
Результат boolean

_compilePot() защищенный Метод

Compiles data into portable object template (POT) format.
protected _compilePot ( resource $stream, array $data ) : boolean
$stream resource
$data array
Результат boolean Success.

_files() защищенный Метод

Returns absolute paths to files according to configuration.
protected _files ( string $category, string $locale, string $scope ) : array
$category string
$locale string
$scope string
Результат array

_init() защищенный Метод

Initializer. Checks if the configured path exists.
protected _init ( ) : void
Результат void

_merge() защищенный Метод

Please note that items with an id containing exclusively whitespace characters or are empty are **not** being merged. Whitespace characters are space, tab, vertical tab, line feed, carriage return and form feed.
См. также: lithium\g11n\catalog\Adapter::_merge()
protected _merge ( array $data, array $item ) : array
$data array Data to merge item into.
$item array Item to merge into $data.
Результат array The merged data.

_parseMo() защищенный Метод

Parses machine object (MO) format, independent of the machine's endian it was created on. Both 32bit and 64bit systems are supported.
protected _parseMo ( resource $stream ) : array
$stream resource
Результат array

_parsePo() защищенный Метод

This parser sacrifices some features of the reference implementation the differences to that implementation are as follows. - No support for comments spanning multiple lines. - Translator and extracted comments are treated as being the same type. - Message IDs are allowed to have other encodings as just US-ASCII. Items with an empty id are ignored. For more information see _merge().
protected _parsePo ( resource $stream ) : array
$stream resource
Результат array

_parsePot() защищенный Метод

Parses portable object template (POT) format.
protected _parsePot ( resource $stream ) : array
$stream resource
Результат array

_prepareForWrite() защищенный Метод

All characters from \000 to \037 (this includes new line and tab characters) as well as the backslash (\) and the double quote (") are escaped. Literal Windows CRLFs (\r\n) are converted to LFs (\n) to improve cross platform compatibility. Escaped single quotes (') are unescaped as they should not need to be. Double escaped characters are maintained and not escaped once again.
См. также: lithium\g11n\catalog\Adapter::_prepareForWrite()
protected _prepareForWrite ( array $item ) : array
$item array
Результат array

_readLong() защищенный Метод

Reads an unsigned long from stream respecting endianess.
protected _readLong ( resource $stream, boolean $isBigEndian ) : integer
$stream resource
$isBigEndian boolean
Результат integer

read() публичный Метод

Reads data.
public read ( string $category, string $locale, string $scope ) : array
$category string A category.
$locale string A locale identifier.
$scope string The scope for the current operation.
Результат array

write() публичный Метод

Writes data.
public write ( string $category, string $locale, string $scope, array $data ) : boolean
$category string A category.
$locale string A locale identifier.
$scope string The scope for the current operation.
$data array The data to write.
Результат boolean