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
파일 보기 프로젝트 열기: unionofrad/lithium 1 사용 예제들

공개 메소드들

메소드 설명
__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