lajax\translatemanager\services\scanners\ScannerFile::extractMessages PHP Method

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
    protected function extractMessages($fileName, $options, $ignoreCategories = [])
    {
        $this->scanner->stdout('Extracting messages from ' . $fileName, Console::FG_GREEN);
        $subject = file_get_contents($fileName);
        if (static::EXTENSION !== '*.php') {
            $subject = "<?php\n" . $subject;
        }
        foreach ($options['translator'] as $currentTranslator) {
            $translatorTokens = token_get_all('<?php ' . $currentTranslator);
            array_shift($translatorTokens);
            $tokens = token_get_all($subject);
            $this->checkTokens($options, $translatorTokens, $tokens);
        }
    }