Abstract Class lajax\translatemanager\services\scanners\ScannerFile

Inheritancelajax\translatemanager\services\scanners\ScannerFile » yii\console\controllers\MessageController
Subclasseslajax\translatemanager\services\scanners\ScannerJavaScriptFunction, lajax\translatemanager\services\scanners\ScannerPhpArray, lajax\translatemanager\services\scanners\ScannerPhpFunction
Available since version1.1

Class for processing PHP and JavaScript files.

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');

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$files array Array to store patsh to project files. lajax\translatemanager\services\scanners\ScannerFile

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
EXTENSION '*.php' Extension of PHP files. lajax\translatemanager\services\scanners\ScannerFile

Property Details

$files protected static property

Array to store patsh to project files.

protected static array $files = ['*.php' => [], '*.js' => []]
$module public property

TranslateManager Module

$scanner public property

Object.

Method Details

__construct() public method

public void __construct ( lajax\translatemanager\services\Scanner $scanner )
$scanner lajax\translatemanager\services\Scanner
checkTokens() protected method

protected void 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 bool containsTranslator ( $translators, $file )
$translators string[]

Array of translator patterns to search (for example: ['::t']).

$file string

Path of the file.

extractMessages() protected method

Extracts messages from a file

protected void extractMessages ( $fileName, $options, $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() protected abstract method

Returns language elements in the token buffer.

If there is no recognisable language element in the array, returns null.

protected abstract void getLanguageItem ( $buffer )
$buffer
init() public method

public void init ( )
initFiles() protected method

protected void initFiles ( )
isValidCategory() protected method

Determines whether the category received as a parameter can be processed.

protected boolean isValidCategory ( $category )
$category string