PHP Class lithium\g11n\catalog\adapter\Code

In fact it allows for extracting messages which are needed to build message catalog templates. Currently only code written in PHP is supported through a parser using the built-in tokenizer.
See also: lithium\g11n\Message
See also: lithium\template\View
Inheritance: extends lithium\g11n\catalog\Adapter
Datei anzeigen Open project: unionofrad/lithium

Public Methods

Method Description
__construct ( array $config = [] ) : void Constructor.
read ( string $category, string $locale, string $scope ) : array Reads data.

Protected Methods

Method Description
_init ( ) Initializer. Checks if the configured path exists.
_merge ( array $data, array $item ) : array Merges an item into given data and removes quotation marks from the beginning and end of message strings.
_parsePhp ( string $file ) : array Parses a PHP file for messages marked as translatable. Recognized as message marking are $t() and $tn() which are implemented in the View class. This is a rather simple and stupid parser but also fast and easy to grasp. It doesn't actively attempt to detect and work around syntax errors in marker functions.
_readMessageTemplate ( string $path ) : array Extracts data from files within configured path recursively.

Method Details

__construct() public method

Constructor.
public __construct ( array $config = [] ) : void
$config array Available configuration options are: - `'path'`: The path to the directory holding the data. - `'scope'`: Scope to use.
return void

_init() protected method

Initializer. Checks if the configured path exists.
protected _init ( )

_merge() protected method

Merges an item into given data and removes quotation marks from the beginning and end of message strings.
See also: 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.
return array The merged data.

_parsePhp() protected method

Parses a PHP file for messages marked as translatable. Recognized as message marking are $t() and $tn() which are implemented in the View class. This is a rather simple and stupid parser but also fast and easy to grasp. It doesn't actively attempt to detect and work around syntax errors in marker functions.
See also: lithium\g11n\Message::aliases()
protected _parsePhp ( string $file ) : array
$file string Absolute path to a PHP file.
return array

_readMessageTemplate() protected method

Extracts data from files within configured path recursively.
protected _readMessageTemplate ( string $path ) : array
$path string Base path to start extracting from.
return array

read() public method

Reads data.
public read ( string $category, string $locale, string $scope ) : array
$category string A category. `'messageTemplate'` is the only category supported.
$locale string A locale identifier.
$scope string The scope for the current operation.
return array Returns the message template. If the scope is not equal to the current scope or `$category` is not `'messageTemplate'` null is returned.