PHP Class lajax\translatemanager\services\scanners\ScannerFile

Language elements detected in JavaScript files: ~~~ lajax.t('language element); lajax.t('language element {replace}', {replace:'String'}); lajax.t("language element"); lajax.t("language element {replace}", {replace:'String'}); ~~~ Language elements detected in PHP files: "t" functions: ~~~ ::t('category of language element', 'language element'); ::t('category of language element', 'language element {replace}', ['replace' => 'String']); ::t('category of language element', "language element"); ::t('category of language element', "language element {replace}", ['replace' => 'String']); ~~~ Language elements detected in constant arrays: ~~~ ** * @translate *\/ private $_GENDERS = ['Male', 'Female']; ** * @translate *\/ private $_STATUSES = [ self::STATUS_ACTIVE => 'Active', self::STATUS_INACTIVE => 'Inactive' ]; ~~~ Translation of constant arrays: Translation to site language: ~~~ $genders = \lajax\translatemanager\helpers\Language::a($this->_GENDERS); ~~~ Translating to the language of your coice: ~~~ $statuses = \lajax\translatemanager\helpers\Language::a($this->_STATUSES, [], 'de-DE'); ~~~
Since: 1.1
Author: Lajos Molnár ([email protected])
Inheritance: extends yii\console\controllers\MessageController
Show file Open project: lajax/yii2-translate-manager

Public Properties

Property Type Description
$module TranslateManager Module
$scanner object.

Protected Properties

Property Type Description
$files Array to store patsh to project files.

Public Methods

Method Description
__construct ( Scanner $scanner )
init ( )

Protected Methods

Method Description
checkTokens ( $options, $translatorTokens, $tokens )
containsTranslator ( string[] $translators, string $file ) : boolean Determines whether the file has any of the translators.
extractMessages ( string $fileName, array $options, array $ignoreCategories = [] ) Extracts messages from a file
getLanguageItem ( $buffer ) Returns language elements in the token buffer.
initFiles ( )
isValidCategory ( string $category ) : boolean Determines whether the category received as a parameter can be processed.

Private Methods

Method Description
_getRoots ( ) : array Returns the root directories to scan.

Method Details

__construct() public method

public __construct ( Scanner $scanner )
$scanner lajax\translatemanager\services\Scanner

checkTokens() protected method

protected checkTokens ( $options, $translatorTokens, $tokens )
$options Definition of the parameters required to identify language elements.
$translatorTokens Translation identification
$tokens Tokens to search through

containsTranslator() protected method

Determines whether the file has any of the translators.
protected containsTranslator ( string[] $translators, string $file ) : boolean
$translators string[] Array of translator patterns to search (for example: `['::t']`).
$file string Path of the file.
return boolean

extractMessages() protected method

Extracts messages from a file
protected extractMessages ( string $fileName, array $options, array $ignoreCategories = [] )
$fileName string name of the file to extract messages from
$options array Definition of the parameters required to identify language elements. example: ~~~ [ 'translator' => ['Yii::t', 'Lx::t'], 'begin' => '(', 'end' => ')' ] ~~~
$ignoreCategories array message categories to ignore Yii 2.0.4

getLanguageItem() abstract protected method

If there is no recognisable language element in the array, returns null.
abstract protected getLanguageItem ( $buffer )

init() public method

public init ( )

initFiles() protected method

protected initFiles ( )

isValidCategory() protected method

Determines whether the category received as a parameter can be processed.
protected isValidCategory ( string $category ) : boolean
$category string
return boolean

Property Details

$files protected static property

Array to store patsh to project files.
protected static $files

$module public property

TranslateManager Module
public $module

$scanner public property

object.
public $scanner